From 45b4ff5c0b824d2e5b51a6af3c44076d05f0214d Mon Sep 17 00:00:00 2001 From: whychdw <496960745@qq.com> Date: 星期三, 18 十二月 2024 13:21:28 +0800 Subject: [PATCH] 内容提交 --- src/views/login/index.vue | 30 +++++++++++++++++++++--------- 1 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/views/login/index.vue b/src/views/login/index.vue index be7c69b..8cc3bc8 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -35,9 +35,8 @@ </template> <script lang="ts"> -import { validUsername } from '@/utils/validate'; import { defineComponent } from 'vue'; -import type { FormItemRule } from 'element-plus'; +import { ElMessage, type FormItemRule } from 'element-plus'; import type { IForm } from '@/types/element-plus'; import store from '@/store'; @@ -57,8 +56,8 @@ } }; const validatePassword: FormItemRule['validator'] = (_rule, value, callback) => { - if (value.length < 6) { - callback(new Error('璇疯緭鍏ュ瘑鐮侊紝鑷冲皯6浣�')); + if (value.length < 1) { + callback(new Error('璇疯緭鍏ュ瘑鐮侊紝鑷冲皯1浣�')); } else { callback(); } @@ -66,7 +65,7 @@ return { loginForm: { username: 'admin', - password: '111111' + password: '1' }, loginRules: { username: [{ required: true, trigger: 'blur', validator: validateUsername }], @@ -101,7 +100,7 @@ } else if (this.loginForm.password === '') { (this.$refs.password as HTMLElement).focus(); } - this.themeChange('blue'); + this.themeChange('blue-theme'); }, unmounted() { // window.removeEventListener('storage', this.afterQRScan) @@ -134,11 +133,24 @@ this.loading = true; store.user().login(this.loginForm) .then(() => { + this.loading = false; this.$router.push({ path: this.redirect || '/', query: this.otherQuery }); + }).catch((error) => { this.loading = false; - }) - .catch(() => { - this.loading = false; + // 璇锋眰澶辫触锛屽鐞嗛敊璇� + if (error.message === 'Network Error') { + // 濡傛灉鏄綉缁滈敊璇紝鏄剧ず涓枃娑堟伅 + ElMessage({ + message: '缃戠粶閿欒锛岃妫�鏌ユ偍鐨勭綉缁滆繛鎺ユ垨鏈嶅姟鍣ㄧ姸鎬併��', + type: 'error' + }); + } else { + // 鍏朵粬绫诲瀷鐨勯敊璇紝鍙互鏍规嵁闇�瑕佸鐞� + ElMessage({ + message: error, + type: 'warning' + }); + } }).finally(() => { resolve(); }); -- Gitblit v1.9.1