| @@ -18,8 +18,6 @@ import request from '@/utils/request'; | |||
| import { API_MODULE_NAME } from '@/config'; | |||
| export function login(data) { | |||
| const url = `/${API_MODULE_NAME.ADMIN}/auth/login`; | |||
| console.log('啦啦啦:', url); | |||
| return request({ | |||
| url: `/${API_MODULE_NAME.ADMIN}/auth/login`, | |||
| method: 'post', | |||
| @@ -90,6 +88,6 @@ export function getUserType() { | |||
| export function getMinIOAuth() { | |||
| return request({ | |||
| url: `/${API_MODULE_NAME.DATA}/datasets/minio/info`, | |||
| // url: 'http://10.0.0.35:8800/api/v1/data/datasets/minio/info', | |||
| // url: 'http://10.0.0.220:8800/api/v1/data/datasets/minio/info', | |||
| }); | |||
| } | |||
| @@ -1,18 +1,10 @@ | |||
| /** Copyright 2020 Tianshu AI Platform. All Rights Reserved. | |||
| * | |||
| * Licensed 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. | |||
| * ============================================================= | |||
| */ | |||
| /** Copyright 2020 Tianshu AI Platform. All Rights Reserved. * * Licensed 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> | |||
| <el-table ref="table" v-loading="loading" :data="data" v-bind="attrs" v-on="$listeners"> | |||
| @@ -12,31 +12,8 @@ the License. * ============================================================= */ | |||
| <div class="container" style="margin-top:80px"> | |||
| <div class="container-box"> | |||
| <div class="bg-img"> | |||
| <!-- <img | |||
| v-if="logoImg1 == false" | |||
| src="~@/assets/images/login/backgroundEn.png" | |||
| alt="" | |||
| /> | |||
| <img | |||
| v-else | |||
| src="~@/assets/images/login/background.png" | |||
| alt="" | |||
| /> --> | |||
| <img | |||
| v-if="parentImg == true" | |||
| src="~@/assets/images/login/background.png" | |||
| alt="" | |||
| /> | |||
| <img | |||
| v-else | |||
| src="~@/assets/images/login/backgroundEn.png" | |||
| alt="" | |||
| /> | |||
| <img v-if="parentImg == true" src="~@/assets/images/login/background.png" alt="" /> | |||
| <img v-else src="~@/assets/images/login/backgroundEn.png" alt="" /> | |||
| </div> | |||
| <div class="slot-content"> | |||
| <login-title></login-title> | |||
| @@ -49,39 +26,25 @@ the License. * ============================================================= */ | |||
| </div> | |||
| </template> | |||
| <script> | |||
| import LoginTitle from "@/components/loginTitle"; | |||
| import ScreenAdapter from "@/components/ScreenAdapter"; | |||
| import LoginTitle from '@/components/loginTitle'; | |||
| import ScreenAdapter from '@/components/ScreenAdapter'; | |||
| export default { | |||
| components: { | |||
| LoginTitle, | |||
| ScreenAdapter, | |||
| }, | |||
| props: ["parentImg"], | |||
| props: ['parentImg'], | |||
| data() { | |||
| return { | |||
| logoImg: true, | |||
| }; | |||
| }, | |||
| // methods: { | |||
| // listenToChild(data) { | |||
| // console.log(data); | |||
| // }, | |||
| // }, | |||
| computed: { | |||
| logoImg1: function () { | |||
| console.log('1111111'); | |||
| console.log(this.logoImg,'222222'); | |||
| console.log(this.parentImg,'3333333'); | |||
| return (this.logoImg = this.parentImg==''?true:this.parentImg); | |||
| logoImg1() { | |||
| return (this.logoImg = this.parentImg == '' ? true : this.parentImg); | |||
| }, | |||
| }, | |||
| // mounted: { | |||
| // }, | |||
| }; | |||
| </script> | |||
| @@ -90,8 +53,7 @@ $green: #39b29b; | |||
| $input-background: #fafbff; | |||
| $white: #fff; | |||
| .login_container { | |||
| background: url("~@/assets/images/login/out-background.png") center center | |||
| no-repeat; | |||
| background: url('~@/assets/images/login/out-background.png') center center no-repeat; | |||
| background-size: 100% 100%; | |||
| position: fixed; | |||
| inset: 0; | |||
| @@ -581,7 +581,10 @@ export default { | |||
| ? ' --train_visualized_log=/workspace/visualizedlog' | |||
| : ''; | |||
| } | |||
| str += this.form.dataSourceName && this.form.dataSourcePath ? ' --data_url=/dataset --label_url=/label' : ''; | |||
| str += | |||
| this.form.dataSourceName && this.form.dataSourcePath | |||
| ? ' --data_url=/dataset --label_url=/label' | |||
| : ''; | |||
| str += | |||
| this.form.valDataSourceName && this.form.valDataSourcePath | |||
| ? ' --val_data_url=/valdataset' | |||
| @@ -213,7 +213,7 @@ export default { | |||
| <span> | |||
| 文件大小需小于100MB,大文件请使用脚本上传, | |||
| <a | |||
| href="https://docs.vloong.thinkenergy.tech/vloong/scene/datamanagement" | |||
| href="https://docs.vloong.thinkenergy.tech/vloong/dev_resources/upload_dataset_script" | |||
| target="_blank" | |||
| type="primary" | |||
| > | |||
| @@ -63,7 +63,6 @@ const user = { | |||
| return new Promise((resolve, reject) => { | |||
| login(loginData) | |||
| .then((res) => { | |||
| console.log('123:', res); | |||
| setToken(res.token, rememberMe); | |||
| initWebSocket(); | |||
| commit('SET_TOKEN', res.token); | |||
| @@ -3,8 +3,8 @@ const lang = { | |||
| title1: 'title1', | |||
| placeholder: 'please enter', | |||
| support: 'Technical support', | |||
| loginBtn: "Return to login", | |||
| ModelText: "Scan for technical support ", | |||
| loginBtn: 'Return to login', | |||
| ModelText: 'Scan for technical support ', | |||
| i18nlogoImg: 'false', | |||
| // 注册页面 | |||
| @@ -53,6 +53,14 @@ const lang = { | |||
| logini18ninthelogin: 'IN THE LOG IN...', | |||
| registrti18ntitle: 'Registration successful', | |||
| // ==== 找回密码 ====== | |||
| resetPsdEmail: 'Please enter your email address', | |||
| resetPsdCode: 'Please enter the email verification code', | |||
| resetPsdPassword: 'Please enter your new password', | |||
| resetPsdPass: 'Please enter your new password again', | |||
| resetPsdBtn: 'Change the password', | |||
| resetPsdBackBtn: 'Return to login', | |||
| resetPsdPassLenght: 'Length in 6-20 characters', | |||
| }; | |||
| export default lang; | |||
| @@ -4,7 +4,7 @@ const lang = { | |||
| placeholder: '请输入中文', | |||
| support: '技术支持', | |||
| loginBtn: '返回登录', | |||
| ModelText: "扫码进群,获取技术支持", | |||
| ModelText: '扫码进群,获取技术支持', | |||
| i18nlogoImg: 'true', | |||
| // 注册页面 | |||
| @@ -52,7 +52,16 @@ const lang = { | |||
| logini18nlogin: '登 录', | |||
| logini18ninthelogin: '登 录 中...', | |||
| registrti18ntitle: '注册成功' | |||
| registrti18ntitle: '注册成功', | |||
| // ==== 找回密码 ====== | |||
| resetPsdEmail: '请输入您的邮箱', | |||
| resetPsdCode: '请输入邮箱验证码', | |||
| resetPsdPassword: '请输入您的新密码', | |||
| resetPsdPass: '请再次确认新密码', | |||
| resetPsdBtn: '修改密码', | |||
| resetPsdBackBtn: '返回登录', | |||
| resetPsdPassLenght: "长度在 6 到 20 个字符" | |||
| }; | |||
| export default lang; | |||
| @@ -363,12 +363,19 @@ export function validateRealName(rule, value, callback) { | |||
| */ | |||
| export function validateNewEmail(rule, value, callback) { | |||
| value = trimStr(value); | |||
| let validatelanguage = sessionStorage.getItem('language_ch'); | |||
| if (value === '' || value == null) { | |||
| callback(); | |||
| } else if (!validEmail(value)) { | |||
| callback(new Error('请输入正确格式的邮箱信息')); | |||
| const msg = (validatelanguage = 'en' | |||
| ? 'Please enter a correct email address' | |||
| : '请输入正确格式的邮箱信息'); | |||
| callback(new Error(msg)); | |||
| } else if (!validEmailSuffix(value)) { | |||
| callback(new Error('请输入正确后缀的邮箱信息')); | |||
| const msg = (validatelanguage = 'en' | |||
| ? 'Please enter a correct email address' | |||
| : '请输入正确后缀的邮箱信息'); | |||
| callback(new Error(msg)); | |||
| } else { | |||
| callback(); | |||
| } | |||
| @@ -43,6 +43,8 @@ the License. * ============================================================= */ | |||
| > | |||
| <algorithm-detail :item="selectedItemObj" /> | |||
| </el-drawer> | |||
| <create-dialog ref="create" @on-add="onAdded" /> | |||
| </div> | |||
| </template> | |||
| @@ -56,7 +58,7 @@ import { createNotebook, getNotebookAddress } from '@/api/development/notebook'; | |||
| import BaseModal from '@/components/BaseModal'; | |||
| import ProTable from '@/components/ProTable'; | |||
| import AlgorithmDetail from '@/components/Training/algorithmDetail'; | |||
| import CreateDialog from '@/views/development/components/CreateDialog'; | |||
| import { getColumns, getQueryFormItems } from './utils'; | |||
| import AlgorithmForm from './components/algorithmForm'; | |||
| @@ -67,9 +69,11 @@ export default { | |||
| ProTable, | |||
| AlgorithmDetail, | |||
| AlgorithmForm, | |||
| CreateDialog, | |||
| }, | |||
| data() { | |||
| return { | |||
| _algorithm: {}, | |||
| ALGORITHM_RESOURCE_ENUM, | |||
| tabs: [ | |||
| { | |||
| @@ -200,10 +204,49 @@ export default { | |||
| type: 'success', | |||
| }); | |||
| }, | |||
| async onAdded() { | |||
| const algorithm = this._algorithm; | |||
| this.disableEdit = true; | |||
| this.notifyInstance = this.$notify({ | |||
| title: '正在启动 Notebook', | |||
| message: '正在启动 Notebook,请稍等', | |||
| iconClass: 'el-icon-loading', | |||
| duration: 0, | |||
| }); | |||
| const notebookInfo = await createNotebook(1, { | |||
| sourceId: algorithm.id, | |||
| sourceFilePath: algorithm.codeDir, | |||
| }).finally(() => { | |||
| this.disableEdit = false; | |||
| }); | |||
| if (notebookInfo.status === 0 && notebookInfo.url) { | |||
| this.openNoteBook(notebookInfo.url, notebookInfo.noteBookName); | |||
| } else { | |||
| this.disableEdit = true; | |||
| this.getNotebookAddress(notebookInfo.id, notebookInfo.noteBookName); | |||
| } | |||
| }, | |||
| async goEdit(algorithm) { | |||
| this._algorithm = algorithm; | |||
| if (this.disableEdit) { | |||
| return; | |||
| } | |||
| // new add | |||
| const res = await createNotebook(1, { | |||
| sourceId: algorithm.id, | |||
| sourceFilePath: algorithm.codeDir, | |||
| }); | |||
| if (!res) { | |||
| this.$refs.create.showThis({ | |||
| sourceId: algorithm.id, | |||
| sourceFilePath: algorithm.codeDir, | |||
| }); | |||
| return; | |||
| } | |||
| // === | |||
| this.disableEdit = true; | |||
| this.notifyInstance = this.$notify({ | |||
| title: '正在启动 Notebook', | |||
| @@ -47,13 +47,13 @@ export function getColumns({ | |||
| label: '名称', | |||
| prop: 'algorithmName', | |||
| fixed: true, | |||
| minWidth: '160px', | |||
| width: '200px', | |||
| }, | |||
| { | |||
| label: '模型类别', | |||
| prop: 'algorithmUsage', | |||
| formatter: getEmptyFormatter(), | |||
| minWidth: '100px', | |||
| width: '100px', | |||
| // dropdownList: allAlgorithmUsageList, | |||
| dropdownList: [ | |||
| { | |||
| @@ -84,7 +84,7 @@ export function getColumns({ | |||
| formatter(value) { | |||
| return value ? '支持' : '不支持'; | |||
| }, | |||
| minWidth: '140px', | |||
| width: '140px', | |||
| dropdownList: [ | |||
| { | |||
| label: '全部', | |||
| @@ -103,24 +103,25 @@ export function getColumns({ | |||
| { | |||
| label: '描述', | |||
| prop: 'description', | |||
| minWidth: '200px', | |||
| width: '200px', | |||
| }, | |||
| { | |||
| label: '创建时间', | |||
| prop: 'createTime', | |||
| type: 'time', | |||
| minWidth: '160px', | |||
| width: '160px', | |||
| sortable: 'custom', | |||
| }, | |||
| { | |||
| label: '创建人', | |||
| prop: 'originUserId', | |||
| width: '100px', | |||
| hide: !isAdmin, | |||
| }, | |||
| { | |||
| label: '操作', | |||
| type: 'operation', | |||
| width: '370px', | |||
| minWidth: '370px', | |||
| fixed: 'right', | |||
| operations: [ | |||
| { | |||
| @@ -1,18 +1,10 @@ | |||
| /** Copyright 2020 Tianshu AI Platform. All Rights Reserved. | |||
| * | |||
| * Licensed 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. | |||
| * ============================================================= | |||
| */ | |||
| /** Copyright 2020 Tianshu AI Platform. All Rights Reserved. * * Licensed 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> | |||
| <BaseModal | |||
| @@ -179,8 +171,12 @@ export default { | |||
| }; | |||
| }, | |||
| methods: { | |||
| showThis() { | |||
| showThis(query = {}) { | |||
| this.showDialog = true; | |||
| this.form = { | |||
| ...query, | |||
| }; | |||
| console.log('form:', this.form); | |||
| }, | |||
| onDialogOpen() { | |||
| this.getHarborProjects().then(() => { | |||
| @@ -68,22 +68,20 @@ the License. * ============================================================= */ | |||
| </el-form-item> | |||
| <!-- 记住我 --> | |||
| <el-form-item> | |||
| <div class="clearfix"> | |||
| <div style="display:flex;justify-content:space-between"> | |||
| <!-- 找回密码 --> | |||
| <!-- <el-button | |||
| type="text" | |||
| style="float: right; vertical-align: middle" | |||
| @click="$router.replace({ path: '/resetpassword' })" | |||
| >{{ $t("logini18nForgotpassword") }}</el-button | |||
| > --> | |||
| <el-button type="text" @click="dialogVisible = true">{{ $t('support') }}</el-button> | |||
| <el-button | |||
| v-if="loginConfig.allowRegister" | |||
| type="text" | |||
| style="float: right; margin-right: 10px; vertical-align: middle" | |||
| @click="$router.replace({ path: '/register' })" | |||
| >{{ $t('logini18nRegister') }}</el-button | |||
| > | |||
| <el-button type="text" @click="$router.replace({ path: '/resetpassword' })">{{ | |||
| $t('logini18nForgotpassword') | |||
| }}</el-button> | |||
| <div> | |||
| <el-button type="text" @click="dialogVisible = true">{{ $t('support') }}</el-button> | |||
| <el-button | |||
| v-if="loginConfig.allowRegister" | |||
| type="text" | |||
| @click="$router.replace({ path: '/register' })" | |||
| >{{ $t('logini18nRegister') }}</el-button | |||
| > | |||
| </div> | |||
| </div> | |||
| <!-- 我已阅读 --> | |||
| <div class="agreement" style="margin-top:10px"> | |||
| @@ -150,7 +150,6 @@ import { | |||
| validateName, | |||
| validateRealName, | |||
| validateAccount, | |||
| validEmail, | |||
| validNewEmail, | |||
| trimStr, | |||
| validateNewEmail, | |||
| @@ -231,7 +230,7 @@ export default { | |||
| // pattern: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/, | |||
| // message: '请输入正确格式的邮箱信息', | |||
| validator: validateNewEmail, | |||
| trigger: ['blur', 'change'], | |||
| trigger: 'blur', | |||
| }, | |||
| ], | |||
| phone: [ | |||
| @@ -272,54 +271,37 @@ export default { | |||
| } | |||
| next(); | |||
| }, | |||
| // beforeRouteLeave(to, from, next) { | |||
| // this.$i18n.locale = "zh-CN"; | |||
| // next(); | |||
| // }, | |||
| mounted() { | |||
| this.buttonName = this.$t('i18nsendverification'); | |||
| const idnexlang = sessionStorage.getItem('language_ch'); | |||
| // 获取用户类型 | |||
| getUserType() | |||
| .then((res) => { | |||
| console.log(res, '获取成功'); | |||
| if (idnexlang == 'Ch') { | |||
| if (idnexlang === 'Ch') { | |||
| this.userTypeList = res; | |||
| console.log('中文'); | |||
| } else if (idnexlang == 'En') { | |||
| this.userTypeList = res; | |||
| this.userTypeList[0].name = 'university users'; | |||
| this.userTypeList[1].name = 'enterprise users'; | |||
| console.log('英文'); | |||
| } | |||
| }) | |||
| .catch((err) => { | |||
| console.log(err); | |||
| }); | |||
| .catch(() => {}); | |||
| // console.log(idnexlang,'======='); | |||
| if (idnexlang == 'Ch') { | |||
| if (idnexlang === 'Ch') { | |||
| this.slelct_Chinese(); | |||
| } else if (idnexlang == 'En') { | |||
| } else if (idnexlang === 'En') { | |||
| this.slelct_english(); | |||
| } | |||
| }, | |||
| methods: { | |||
| // 语言切换 | |||
| // changeLocale() { | |||
| // this.$i18n.locale = this.$i18n.locale === 'en' ? 'zh-CN' : 'en'; | |||
| // }, | |||
| // 切换中文 | |||
| slelct_Chinese() { | |||
| getUserType() | |||
| .then((res) => { | |||
| this.userTypeList = res; | |||
| }) | |||
| .catch((err) => { | |||
| console.log(err); | |||
| }); | |||
| .catch(() => {}); | |||
| this.parentImg = true; | |||
| const language_ch = this.$i18n.locale; | |||
| sessionStorage.setItem('language_ch', 'Ch'); | |||
| this.$refs.registerForm.resetFields(); | |||
| this.$refs.registerForm.clearValidate(); | |||
| @@ -348,9 +330,7 @@ export default { | |||
| this.userTypeList[0].name = 'university users'; | |||
| this.userTypeList[1].name = 'enterprise users'; | |||
| }) | |||
| .catch((err) => { | |||
| console.log(err); | |||
| }); | |||
| .catch(() => {}); | |||
| this.parentImg = false; | |||
| sessionStorage.setItem('language_ch', 'En'); | |||
| this.$refs.registerForm.resetFields(); | |||
| @@ -401,7 +381,7 @@ export default { | |||
| } else { | |||
| this.buttonName = 'Sending'; | |||
| successMsg = 'send success,valid for 5 minutes'; | |||
| btnMsg = 'resend'; | |||
| btnMsg = 'Resend'; | |||
| } | |||
| const codeData = { | |||
| @@ -479,9 +459,14 @@ export default { | |||
| this.$router.replace({ path: '/login' }); | |||
| }) | |||
| .catch((err) => { | |||
| const msg = err.message; | |||
| let str; | |||
| if (msg === '用户名已存在!') { | |||
| str = this.$i18n.locale === 'en' ? 'Username already exists!' : '用户名已存在!'; | |||
| } | |||
| this.loading = false; | |||
| this.$message({ | |||
| message: err.message, | |||
| message: str || err.message, | |||
| type: 'error', | |||
| }); | |||
| }); | |||
| @@ -21,7 +21,7 @@ the License. * ============================================================= */ | |||
| <el-input | |||
| v-model="registerForm.email" | |||
| auto-complete="on" | |||
| placeholder="请输入您的邮箱" | |||
| :placeholder="$t('resetPsdEmail')" | |||
| > | |||
| <i slot="prefix" class="el-input__icon el-icon-message" /> | |||
| </el-input> | |||
| @@ -30,7 +30,7 @@ the License. * ============================================================= */ | |||
| <el-input | |||
| v-model="registerForm.code" | |||
| style="width: 57%" | |||
| placeholder="请输入邮箱验证码" | |||
| :placeholder="$t('resetPsdCode')" | |||
| > | |||
| <i slot="prefix" class="el-input__icon el-icon-circle-check" /> | |||
| </el-input> | |||
| @@ -47,17 +47,13 @@ the License. * ============================================================= */ | |||
| <el-input | |||
| v-model="registerForm.password" | |||
| type="password" | |||
| placeholder="请输入您的新密码" | |||
| :placeholder="$t('resetPsdPassword')" | |||
| > | |||
| <i slot="prefix" class="el-input__icon el-icon-lock" /> | |||
| </el-input> | |||
| </el-form-item> | |||
| <el-form-item prop="pass"> | |||
| <el-input | |||
| v-model="registerForm.pass" | |||
| type="password" | |||
| placeholder="请再次确认新密码" | |||
| > | |||
| <el-input v-model="registerForm.pass" type="password" :placeholder="$t('resetPsdPass')"> | |||
| <i slot="prefix" class="el-input__icon el-icon-key" /> | |||
| </el-input> | |||
| </el-form-item> | |||
| @@ -68,14 +64,11 @@ the License. * ============================================================= */ | |||
| class="my-btn" | |||
| style="width: 100%" | |||
| @click="submitForm('registerForm')" | |||
| >修改密码</el-button | |||
| > | |||
| <el-button | |||
| type="text" | |||
| class="fr" | |||
| @click="$router.replace({ path: '/login' })" | |||
| >返回登录</el-button | |||
| >{{ $t('resetPsdBtn') }}</el-button | |||
| > | |||
| <el-button type="text" class="fr" @click="$router.replace({ path: '/login' })">{{ | |||
| $t('resetPsdBackBtn') | |||
| }}</el-button> | |||
| </el-form-item> | |||
| </el-form> | |||
| </login-public> | |||
| @@ -83,86 +76,89 @@ the License. * ============================================================= */ | |||
| </template> | |||
| <script> | |||
| import { encrypt } from "@/utils/rsaEncrypt"; | |||
| import { getCodeBySentEmail, resetPassword } from "@/api/auth"; | |||
| import LoginPublic from "@/components/LoginPublic"; | |||
| import { encrypt } from '@/utils/rsaEncrypt'; | |||
| import { getCodeBySentEmail, resetPassword } from '@/api/auth'; | |||
| import LoginPublic from '@/components/LoginPublic'; | |||
| import { validateNewEmail } from '@/utils/validate'; | |||
| export default { | |||
| name: "ResetPassword", | |||
| name: 'ResetPassword', | |||
| components: { | |||
| LoginPublic, | |||
| }, | |||
| data() { | |||
| const validatePass2 = (rule, value, callback) => { | |||
| if (value === "") { | |||
| callback(new Error("请再次输入新密码")); | |||
| if (value === '') { | |||
| const msg = (this.$i18n.locale = 'en' | |||
| ? 'Please enter your new password' | |||
| : '新密码不能为空'); | |||
| callback(new Error(msg)); | |||
| } else if (value !== this.registerForm.password) { | |||
| callback(new Error("两次输入密码不一致!")); | |||
| const msg = (this.$i18n.locale = 'en' | |||
| ? 'Please enter your new password again' | |||
| : '请再次验证密码'); | |||
| callback(new Error(msg)); | |||
| } else { | |||
| callback(); | |||
| } | |||
| }; | |||
| return { | |||
| // 传给子组件的值 | |||
| // 传给子组件的值 | |||
| parentImg: true, | |||
| buttonName: "发送验证码", | |||
| buttonName: '', | |||
| isDisabled: false, | |||
| time: 60, | |||
| codeLoading: false, | |||
| registerForm: { | |||
| username: "", | |||
| phone: "", | |||
| nickName: "", | |||
| email: "", | |||
| code: "", | |||
| password: "", | |||
| sex: "", | |||
| pass: "", | |||
| username: '', | |||
| phone: '', | |||
| nickName: '', | |||
| email: '', | |||
| code: '', | |||
| password: '', | |||
| sex: '', | |||
| pass: '', | |||
| }, | |||
| registerRules: { | |||
| email: [ | |||
| { required: true, message: "请输入邮箱地址", trigger: "blur" }, | |||
| { required: true, message: this.$t('resetPsdEmail'), trigger: 'blur' }, | |||
| { | |||
| pattern: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/, | |||
| message: "请输入正确的邮箱地址", | |||
| trigger: ["blur", "change"], | |||
| validator: validateNewEmail, | |||
| trigger: ['blur', 'change'], | |||
| }, | |||
| ], | |||
| code: [ | |||
| { required: true, trigger: "change", message: "验证码不能为空" }, | |||
| ], | |||
| code: [{ required: true, trigger: 'change', message: this.$t('resetPsdCode') }], | |||
| password: [ | |||
| { required: true, trigger: "blur", message: "新密码不能为空" }, | |||
| { required: true, trigger: 'blur', message: this.$t('resetPsdPassword') }, | |||
| { | |||
| min: 6, | |||
| max: 20, | |||
| message: "长度在 6 到 20 个字符", | |||
| trigger: "blur", | |||
| message: this.$t('resetPsdPassLenght'), | |||
| trigger: 'blur', | |||
| }, | |||
| ], | |||
| pass: [ | |||
| { required: true, message: "请再次验证密码", trigger: "blur" }, | |||
| { validator: validatePass2, trigger: "blur" }, | |||
| ], | |||
| pass: [{ validator: validatePass2, trigger: 'blur' }], | |||
| }, | |||
| loading: false, | |||
| }; | |||
| }, | |||
| created() { | |||
| this.buttonName = this.$i18n.locale === 'en' ? 'Send code' : '发送验证码'; | |||
| }, | |||
| mounted() { | |||
| let idnexlang1 = sessionStorage.getItem("language_ch"); | |||
| console.log(idnexlang1, "========"); | |||
| if (idnexlang1 == "zh-CN" || idnexlang1 == null) { | |||
| // 传给子组件的值 | |||
| const idnexlang1 = sessionStorage.getItem('language_ch'); | |||
| if (idnexlang1 === 'zh-CN' || idnexlang1 == null) { | |||
| this.parentImg = true; | |||
| } else if (idnexlang1 == "En") { | |||
| } else if (idnexlang1 === 'En') { | |||
| // 传给子组件的值 | |||
| this.parentImg = false; | |||
| } | |||
| }, | |||
| methods: { | |||
| sendCode() { | |||
| const flag = this.$i18n.locale === 'en'; | |||
| this.codeLoading = true; | |||
| this.buttonName = "发送中"; | |||
| this.buttonName = flag ? 'Sending' : '发送中'; | |||
| const codeData = { | |||
| email: this.registerForm.email, | |||
| type: 4, | |||
| @@ -171,8 +167,8 @@ export default { | |||
| .then(() => { | |||
| this.$message({ | |||
| showClose: true, | |||
| message: "发送成功,验证码有效期5分钟", | |||
| type: "success", | |||
| message: flag ? 'send success,valid for 5 minutes' : '发送成功,验证码有效期5分钟', | |||
| type: 'success', | |||
| }); | |||
| this.codeLoading = false; | |||
| this.isDisabled = true; | |||
| @@ -181,7 +177,7 @@ export default { | |||
| this.buttonName = `${this.time}秒`; | |||
| this.time -= 1; | |||
| if (this.time < 0) { | |||
| this.buttonName = "重新发送"; | |||
| this.buttonName = flag ? 'Resend' : '重新发送'; | |||
| this.time = 60; | |||
| this.isDisabled = false; | |||
| window.clearInterval(this.timer); | |||
| @@ -191,9 +187,21 @@ export default { | |||
| .catch((err) => { | |||
| this.resetForm(); | |||
| this.codeLoading = false; | |||
| const msg = err.message; | |||
| let str = ''; | |||
| if (msg === '邮箱地址不能为空') { | |||
| str = | |||
| this.$i18n.locale === 'en' ? 'The email address cannot be blank' : '邮箱地址不能为空'; | |||
| } | |||
| if (msg === '邮箱地址格式有误') { | |||
| str = | |||
| this.$i18n.locale === 'en' | |||
| ? 'The email address format is incorrect' | |||
| : '邮箱地址格式有误'; | |||
| } | |||
| this.$message({ | |||
| message: err.message, | |||
| type: "error", | |||
| message: str || err.message, | |||
| type: 'error', | |||
| }); | |||
| }); | |||
| }, | |||
| @@ -210,17 +218,17 @@ export default { | |||
| this.loading = false; | |||
| this.resetForm(); | |||
| this.$notify({ | |||
| title: "密码修改成功", | |||
| type: "success", | |||
| title: '密码修改成功', | |||
| type: 'success', | |||
| duration: 1500, | |||
| }); | |||
| this.$router.replace({ path: "/login" }); | |||
| this.$router.replace({ path: '/login' }); | |||
| }) | |||
| .catch((err) => { | |||
| this.loading = false; | |||
| this.$message({ | |||
| message: err.message, | |||
| type: "error", | |||
| type: 'error', | |||
| }); | |||
| }); | |||
| return true; | |||
| @@ -233,13 +241,13 @@ export default { | |||
| this.$refs.registerForm.resetFields(); | |||
| window.clearInterval(this.timer); | |||
| this.time = 60; | |||
| this.buttonName = "发送验证码"; | |||
| this.buttonName = this.$i18n.locale === 'en' ? 'Send code' : '发送验证码'; | |||
| this.isDisabled = false; | |||
| this.registerForm = { | |||
| email: "", | |||
| code: "", | |||
| password: "", | |||
| pass: "", | |||
| email: '', | |||
| code: '', | |||
| password: '', | |||
| pass: '', | |||
| }; | |||
| }, | |||
| }, | |||
| @@ -247,7 +255,7 @@ export default { | |||
| </script> | |||
| <style rel="stylesheet/scss" lang="scss" scoped> | |||
| @import "@/assets/styles/variables.scss"; | |||
| @import '@/assets/styles/variables.scss'; | |||
| .register-title { | |||
| margin: 0 auto 30px; | |||