From dc581d7185476c9f36d485ca7ea67131cb2231bd Mon Sep 17 00:00:00 2001 From: lww9029 <756794909@qq.com> Date: Tue, 13 Oct 2026 10:36:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=B8=8B=E8=BF=98=E8=83=BD=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E7=99=BD=E5=90=8D=E5=8D=95=E8=B7=AF=E7=94=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/manager-web/src/router/index.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/main/manager-web/src/router/index.js b/main/manager-web/src/router/index.js index d4b486e97..a47f1b4e5 100644 --- a/main/manager-web/src/router/index.js +++ b/main/manager-web/src/router/index.js @@ -197,16 +197,22 @@ const anonRouteNames = new Set(['login', 'Register', 'RetrievePassword', 'welcom // 路由守卫 router.beforeEach((to, from, next) => { - if (anonRouteNames.has(to.name)) { - next() + const token = localStorage.getItem('token'); + const isAnonRoute = anonRouteNames.has(to.name); + + if (isAnonRoute && token) { + next({ name: 'home', replace: true }) return } - // 非白名单路由必须登录 - const token = localStorage.getItem('token') - if (!token) { - next({ name: 'login' }) + + if (!isAnonRoute && !token) { + next({ + name: 'login', + replace: true + }) return } + next() })