From 4f8686b35e807dfcf0b3edc36bedcffe44f50833 Mon Sep 17 00:00:00 2001 From: H0nGzA1 <2505811377@qq.com> Date: Tue, 28 Mar 2023 21:21:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20=E7=99=BB=E5=BD=95=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=EF=BC=8C=E8=87=AA=E5=8A=A8=E5=88=B7=E6=96=B0=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/system/login/component/account.vue | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/web/src/views/system/login/component/account.vue b/web/src/views/system/login/component/account.vue index 165e4e8..6b92ffb 100644 --- a/web/src/views/system/login/component/account.vue +++ b/web/src/views/system/login/component/account.vue @@ -121,19 +121,24 @@ export default defineComponent({ }); }; const loginClick = async () => { - loginApi.login({ ...state.ruleForm, password: Md5.hashStr(state.ruleForm.password) }).then((ret: any) => { - Session.set('token', ret.data.access); - Cookies.set('username', ret.data.name); - if (!themeConfig.value.isRequestRoutes) { - // 前端控制路由,2、请注意执行顺序 - initFrontEndControlRoutes(); - loginSuccess(); - } else { - // 模拟后端控制路由,isRequestRoutes 为 true,则开启后端控制路由 - // 添加完动态路由,再进行 router 跳转,否则可能报错 No match found for location with path "/" - initBackEndControlRoutes(); - // 执行完 initBackEndControlRoutes,再执行 signInSuccess - loginSuccess(); + loginApi.login({ ...state.ruleForm, password: Md5.hashStr(state.ruleForm.password) }).then((res: any) => { + if (res.code === 2000) { + Session.set('token', res.data.access); + Cookies.set('username', res.data.name); + if (!themeConfig.value.isRequestRoutes) { + // 前端控制路由,2、请注意执行顺序 + initFrontEndControlRoutes(); + loginSuccess(); + } else { + // 模拟后端控制路由,isRequestRoutes 为 true,则开启后端控制路由 + // 添加完动态路由,再进行 router 跳转,否则可能报错 No match found for location with path "/" + initBackEndControlRoutes(); + // 执行完 initBackEndControlRoutes,再执行 signInSuccess + loginSuccess(); + } + } else if (res.code === 4000) { + // 登录错误之后,刷新验证码 + refreshCaptcha(); } }); };