diff --git a/src/router/guard/permissionGuard.ts b/src/router/guard/permissionGuard.ts index 09027b82d27..4d394142788 100644 --- a/src/router/guard/permissionGuard.ts +++ b/src/router/guard/permissionGuard.ts @@ -29,14 +29,24 @@ export function createPermissionGuard(router: Router) { return; } + const token = userStore.getToken; + // Whitelist can be directly entered if (whitePathList.includes(to.path as PageEnum)) { + if (to.path === LOGIN_PATH && token) { + const isSessionTimeout = userStore.getSessionTimeout; + try { + await userStore.afterLoginAction(); + if (!isSessionTimeout) { + next((to.query?.redirect as string) || '/'); + return; + } + } catch {} + } next(); return; } - const token = userStore.getToken; - // token does not exist if (!token) { // You can access without permission. You need to set the routing meta.ignoreAuth to true