From 49dd3f726a5564f6ccfb7a6890db8b48b325c385 Mon Sep 17 00:00:00 2001 From: Allen Date: Thu, 16 May 2024 10:54:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=B7=AF=E7=94=B1=E5=9B=9E?= =?UTF-8?q?=E8=B7=B3=E7=BC=BA=E9=99=B7=EF=BC=881=E3=80=81=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E9=80=80=E5=87=BA=E5=90=8E=E9=87=8D=E6=96=B0=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E4=BC=9A=E9=94=99=E8=AF=AF=E5=9C=B0=E5=9B=9E=E5=88=B0?= =?UTF-8?q?=E4=B8=8A=E6=AC=A1=E4=B8=A2=E5=A4=B1=E8=AE=A4=E8=AF=81=E6=97=B6?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=9A=84=E8=B7=AF=E7=94=B1=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=EF=BC=9B2=E3=80=81=E5=90=8E=E7=AB=AF=E6=8E=A5=E5=8F=A3403?= =?UTF-8?q?=E6=97=B6=E4=BC=9A=E9=94=99=E8=AF=AF=E5=9C=B0=E5=9B=9E=E5=88=B0?= =?UTF-8?q?=E4=B8=8A=E6=AC=A1=E4=B8=A2=E5=A4=B1=E8=AE=A4=E8=AF=81=E6=97=B6?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=9A=84=E8=B7=AF=E7=94=B1=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E8=80=8C=E4=B8=8D=E6=98=AF=E5=BD=93=E5=89=8D=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layouts/components/UserProfile.vue | 3 ++- src/router/index.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/layouts/components/UserProfile.vue b/src/layouts/components/UserProfile.vue index da97373f..5c2cbd2a 100644 --- a/src/layouts/components/UserProfile.vue +++ b/src/layouts/components/UserProfile.vue @@ -23,7 +23,8 @@ const progressDialog = ref(false) function logout() { // 清除登录状态信息 store.dispatch('auth/clearToken') - + // 主动登出时清除路由标记 + store.state.auth.originalPath = null // 重定向到登录页面或其他适当的页面 router.push('/login') } diff --git a/src/router/index.ts b/src/router/index.ts index c406c54c..54498891 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -159,10 +159,11 @@ const router = createRouter({ // 路由导航守卫 router.beforeEach((to, from, next) => { + // 总是记录非login路由 + if (to.fullPath != '/login') store.state.auth.originalPath = to.fullPath const isAuthenticated = store.state.auth.token !== null if (to.meta.requiresAuth && !isAuthenticated) { - store.state.auth.originalPath = to.fullPath next('/login') } else {