fix: cookie expire redirect

This commit is contained in:
engigu
2025-09-20 15:57:05 +08:00
parent cdf96fee0b
commit abc15e3b84
2 changed files with 37 additions and 16 deletions
+7 -4
View File
@@ -83,13 +83,16 @@ router.beforeEach((to, from, next) => {
return;
}
// 如果没有token且不是访问登录页,跳转到登录页
if (!isAuthenticated && to.path !== '/login') {
next('/login');
} else if (isAuthenticated && to.path === '/login') {
}
// 如果有token且访问登录页,跳转到首页
else if (isAuthenticated && to.path === '/login') {
next('/');
} else {
}
// 其他情况正常访问
else {
next();
}
});