From 0c620ef5b43f0277f72a32ab5a6cf20118fc1f1b Mon Sep 17 00:00:00 2001 From: deary Date: Fri, 17 May 2024 11:44:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95=E5=A4=B1?= =?UTF-8?q?=E6=95=88=EF=BC=8C=E5=86=8D=E6=AC=A1=E7=99=BB=E5=BD=95=E4=B8=A2?= =?UTF-8?q?=E5=A4=B1=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/permission.ts | 3 ++- src/views/login.vue | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/permission.ts b/src/permission.ts index ef9976a..1123738 100644 --- a/src/permission.ts +++ b/src/permission.ts @@ -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(); } } diff --git a/src/views/login.vue b/src/views/login.vue index 060703b..3616d09 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -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;