修复登录失效,再次登录丢失参数

This commit is contained in:
deary 2024-05-17 11:44:33 +08:00
parent 9b00aaff93
commit 0c620ef5b4
2 changed files with 4 additions and 2 deletions

View File

@ -52,7 +52,8 @@ router.beforeEach(async (to, from, next) => {
// 在免登录白名单,直接进入
next();
} else {
next(`/login?redirect=${to.fullPath}`); // 否则全部重定向到登录页
const redirect = encodeURIComponent(to.fullPath || '/');
next(`/login?redirect=${redirect}`) // 否则全部重定向到登录页
NProgress.done();
}
}

View File

@ -130,7 +130,8 @@ const handleLogin = () => {
// action
const [err] = await to(userStore.login(loginForm.value));
if (!err) {
await router.push({ path: redirect.value || '/' });
const redirectUrl = redirect.value || '/';
await router.push(redirectUrl);
loading.value = false;
} else {
loading.value = false;