@@ -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();
}
@@ -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;