fix: 登录后访问/auth/login应该跳转到首页

This commit is contained in:
dap 2024-08-07 09:40:36 +08:00
parent 14a5201bc7
commit eeb5c55c5f

View File

@ -62,14 +62,20 @@ function setupAccessGuard(router: Router) {
const userStore = useUserStore(); const userStore = useUserStore();
const authStore = useAuthStore(); const authStore = useAuthStore();
// 基本路由,这些路由不需要进入权限拦截
if (coreRouteNames.includes(to.name as string)) {
if (to.path === LOGIN_PATH && accessStore.accessToken) {
return decodeURIComponent(
(to.query?.redirect as string) || DEFAULT_HOME_PATH,
);
}
return true;
}
// accessToken 检查 // accessToken 检查
if (!accessStore.accessToken) { if (!accessStore.accessToken) {
if ( // 明确声明忽略权限访问权限,则可以访问
// 基本路由,这些路由不需要进入权限拦截 if (to.meta.ignoreAccess) {
coreRouteNames.includes(to.name as string) ||
// 明确声明忽略权限访问权限,则可以访问
to.meta.ignoreAccess
) {
return true; return true;
} }
@ -87,15 +93,6 @@ function setupAccessGuard(router: Router) {
} }
const accessRoutes = accessStore.accessRoutes; const accessRoutes = accessStore.accessRoutes;
/**
*
*/
if (to.path === LOGIN_PATH) {
return {
path: DEFAULT_HOME_PATH,
replace: true,
};
}
// 是否已经生成过动态路由 // 是否已经生成过动态路由
if (accessRoutes && accessRoutes.length > 0) { if (accessRoutes && accessRoutes.length > 0) {