From e6d6cc6b8327fc28dd79b9b91f742c89338644d4 Mon Sep 17 00:00:00 2001 From: deary Date: Sun, 12 May 2024 23:04:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E7=99=BB=E5=BD=95=E6=88=90=E5=8A=9F?= =?UTF-8?q?=EF=BC=8C=E4=B8=A2=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 c819ff4..3f6d64d 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 e5c73fa..c96db82 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -124,7 +124,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;