Copilot commented on code in PR #697: URL: https://github.com/apache/dubbo-go-pixiu/pull/697#discussion_r2209249929
########## web/vue.config.js: ########## @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +const path = require('path'); + +const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin + +// const ThreeExamples = require('import-three-examples') +function resolve(dir) { + return path.join(__dirname,'.', dir); +} + +module.exports = { + baseUrl : '/', Review Comment: The 'baseUrl' option is deprecated in newer Vue CLI versions; prefer using 'publicPath' only. ```suggestion ``` ########## web/src/views/Screen.vue: ########## @@ -0,0 +1,58 @@ +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + --> +<template> + <div id="app"> + <router-view/> + </div> +</template> + + +<script> + +export default { + name: "app", + components: {}, + mounted() { + this.init() + }, + methods: { + async init() { + await this.getData() + this.getNowData() + }, + async getData() { + setTimeout(function(){ + console.log(111) + }, 5000) + clearTimeout() Review Comment: clearTimeout is called without a timer ID, so the timeout cannot be canceled. Store the return value from setTimeout and pass it into clearTimeout. ```suggestion const timerId = setTimeout(function(){ console.log(111) }, 5000) clearTimeout(timerId) ``` ########## web/vue.config.js: ########## @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +const path = require('path'); + +const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin + +// const ThreeExamples = require('import-three-examples') +function resolve(dir) { + return path.join(__dirname,'.', dir); +} + +module.exports = { + baseUrl : '/', + publicPath : '/', + productionSourceMap: true, + chainWebpack: config => { + config.resolve.alias + .set('@', resolve('src')) + .set('@assets',resolve('src/assets')) + .set('styles',resolve('src/styles')) + .set('@utils',resolve('src/utils')) + .set('@views',resolve('src/views')) + }, + devServer:{ + // 设置代理 + // before: require('./src/mock'), + host: '0.0.0.0', + port: 8080, + hot: true, + https: false, + open: false, + disableHostCheck: true, + proxy: { + "/config": { + target: process.env.VUE_APP_BACKEND_URL, + ws: true, // enable websocket proxy + changOrigin: true, // enable proxy module Review Comment: Typo in proxy configuration: 'changOrigin' should be 'changeOrigin' to correctly set the proxy's changeOrigin option. ```suggestion changeOrigin: true, // enable proxy module ``` ########## web/src/views/dashboard/personInfo/userInfo.vue: ########## @@ -0,0 +1,300 @@ +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + --> +<template> +<div> + <el-form ref="form" :model="user" :rules="rules" label-width="80px"> + <el-form-item label="用户名称" prop="username"> + <el-input v-model="user.username" disabled maxlength="12" /> + </el-form-item> + <el-form-item label="旧密码" prop="oldPassword" > + <el-input v-model="user.oldPassword" maxlength="12" /> + </el-form-item> + <el-form-item label="新密码" prop="newPassword"> + <el-input v-model="user.newPassword" maxlength="12" /> + </el-form-item> + <el-form-item> + <el-button type="primary" size="mini" @click="submit">保存</el-button> + <!-- <el-button type="danger" size="mini" @click="close">关闭</el-button> --> + </el-form-item> + </el-form> + <div> + <el-dialog + title="短信验证码" + :visible.sync="dialogVisible" + width="300px" + :before-close="handleClose"> + <div class="login"> + <!-- 手机号 --> + <InputGroup + placeholder="手机号" + v-model="phone" + :error="errors.phone" + :disableInput="myDisable" + /> + <!-- 输入验证码 --> + <InputGroup + v-model="verifyCode" + placeholder="验证码" + :error="errors.code" + :btnTitle="btnTitle" + :disabled="disabled" + @btnClick="getVerifyCode" + /> + <!-- 登录按钮 --> + + <div class="login_btn"> + <button @click="handleLogin" :disabled="isClick">确 定</button> + </div> + </div> + </el-dialog> + </div> +</div> +</template> + +<script> +import InputGroup from '@/components/InputGroup' +import api from '@/api' +import fetch from '@/utils/fetch' +import {mapGetters, mapActions} from 'vuex' +import { getToken, setToken, removeToken, getLocalStorage, setLocalStorage,clearLocalStorage } from '@/utils/auth' +export default { + components:{InputGroup}, + props: { + + }, + data() { + return { + myDisable:true, + phone:"", //手机号 + verifyCode:"", //验证码 + btnTitle:"获取验证码", + disabled:false, //是否可点击 + errors:{}, //验证提示信息 + dialogVisible:false, + user:{ + username:"", + oldPassword:"", + newPassword:'' + }, + // 表单校验 + rules: { + username: [ + { required: true, message: "用户名称不能为空", trigger: "blur" } + ], + oldPassword: [ + { required: true, message: "旧密码不能为空", trigger: "blur" } + ], + newPassword: [ + { required: true, message: "新密码不能为空", trigger: "blur" } + ] + } + }; + }, + created() { + this.user.username = getLocalStorage('operatorInfo').username + }, + computed: { + ...mapGetters([ + 'operatorInfo' + ]), + + //手机号和验证码都不能为空 + isClick(){ + if(!this.phone || !this.verifyCode) { + return true + } else { + return false + } + + } + }, + methods: { + ...mapActions([ + 'setOperatorInfo', + 'setToken', + ]), + submit() { + this.$refs["form"].validate(valid => { + if (valid) { + let formData = new FormData(); + formData.append('username', this.user.username); + formData.append('oldPassword', this.user.oldPassword); + formData.append('newPassword', this.user.newPassword); + fetch({ + url: api['getPasswordEdit'].url || '', + method: 'post', + data: formData + }).then(res => { + console.log(res, '=====>1') + this.$msgbox({ + message: "密码修改成功", + title: '成功', + customClass: 'my_msgBox singelBtn', + dangerouslyUseHTMLString: true, + confirmButtonText: '确定', + type: 'success' + }) + }).catch(error => { + console.log(error); + this.$msgbox({ + message: error.message, + title: '失败', + customClass: 'my_msgBox singelBtn', + dangerouslyUseHTMLString: true, + confirmButtonText: '确定', + type: 'error' + }) + }); + } + }); + }, + getVerifyCode(){ + //获取验证码 + if(this.validatePhone()) { + let params = { + url: api['operatorSendSms'].url, + method: 'post', + data: { + opId: this.operatorInfo.op_code, + phone: this.phone, + smsType: 3 + } + } + fetch(params).then(res => { + this.$msgbox({ + message: '发送成功', + title: '成功', + customClass: 'my_msgBox singelBtn', + dangerouslyUseHTMLString: true, + confirmButtonText: '确定', + type: 'success' + }) + this.validateBtn() + }).catch(error => { + this.$msgbox({ + message: error.message, + title: '失败', + customClass: 'my_msgBox singelBtn', + dangerouslyUseHTMLString: true, + confirmButtonText: '确定', + type: 'error' + }) + }) + } + }, + handleLogin() { + let params = { + url: api['operatorUpdateData'].url, + method: 'post', + data: { + code: this.verifyCode, + email: this.user.email, + opId: this.operatorInfo.op_code, + phone: this.phone, + sex: this.user.sex, + address: "", + } + } + fetch(params).then(res => { + this.$msgbox({ + message: '数据保存成功', + title: '成功', + customClass: 'my_msgBox singelBtn', + dangerouslyUseHTMLString: true, + confirmButtonText: '确定', + type: 'success' + }) + let data = this.operatorInfo; + Object.assign(data, this.user) + this.setOperatorInfo(data) + this.dialogVisible = false + }).catch(error => { + this.$msgbox({ + message: error.message, + title: '失败', + customClass: 'my_msgBox singelBtn', + dangerouslyUseHTMLString: true, + confirmButtonText: '确定', + type: 'error' + }) + }) + }, + validateBtn(){ + //倒计时 + let time = 60; + let timer = setInterval(() => { + if(time == 0) { + clearInterval(timer); + this.disabled = false; + this.btnTitle = "获取验证码"; + } else { + this.btnTitle =time + '秒后重试'; + this.disabled = true; + time-- + } + },1000) + }, + handleClose() { + this.dialogVisible = false + }, + validatePhone(){ + //判断输入的手机号是否合法 + if(!this.phone) { + this.errors = { + phone:"手机号码不能为空" + } + // return false + } else if(!/^1[345678]\d{9}$/.test(this.phone)) { + this.errors = { + phone:"请输入正确是手机号" Review Comment: Error message text has a typo: '请输入正确是手机号' should be '请输入正确的手机号'. ```suggestion phone:"请输入正确的手机号" ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
