feat: 登录页面,自动刷新验证码

This commit is contained in:
H0nGzA1
2023-03-28 21:21:05 +08:00
parent 8710b047b1
commit c5d7a70f46

View File

@@ -121,19 +121,24 @@ export default defineComponent({
}); });
}; };
const loginClick = async () => { const loginClick = async () => {
loginApi.login({ ...state.ruleForm, password: Md5.hashStr(state.ruleForm.password) }).then((ret: any) => { loginApi.login({ ...state.ruleForm, password: Md5.hashStr(state.ruleForm.password) }).then((res: any) => {
Session.set('token', ret.data.access); if (res.code === 2000) {
Cookies.set('username', ret.data.name); Session.set('token', res.data.access);
if (!themeConfig.value.isRequestRoutes) { Cookies.set('username', res.data.name);
// 前端控制路由2、请注意执行顺序 if (!themeConfig.value.isRequestRoutes) {
initFrontEndControlRoutes(); // 前端控制路由2、请注意执行顺序
loginSuccess(); initFrontEndControlRoutes();
} else { loginSuccess();
// 模拟后端控制路由isRequestRoutes 为 true则开启后端控制路由 } else {
// 添加完动态路由,再进行 router 跳转,否则可能报错 No match found for location with path "/" // 模拟后端控制路由isRequestRoutes 为 true则开启后端控制路由
initBackEndControlRoutes(); // 添加完动态路由,再进行 router 跳转,否则可能报错 No match found for location with path "/"
// 执行完 initBackEndControlRoutes,再执行 signInSuccess initBackEndControlRoutes();
loginSuccess(); // 执行完 initBackEndControlRoutes再执行 signInSuccess
loginSuccess();
}
} else if (res.code === 4000) {
// 登录错误之后,刷新验证码
refreshCaptcha();
} }
}); });
}; };