diff --git a/src/router/guard/route.ts b/src/router/guard/route.ts index c995923..b8285be 100644 --- a/src/router/guard/route.ts +++ b/src/router/guard/route.ts @@ -40,7 +40,12 @@ export function createRouteGuard(router: Router) { // if it is login route when logged in, then switch to the root page if (to.name === loginRoute && isLogin) { - next({ name: rootRoute }); + const redirect = to.query?.redirect as string; + if (redirect) { + next({ path: redirect }); + } else { + next({ name: rootRoute }); + } return; } diff --git a/src/store/modules/auth/index.ts b/src/store/modules/auth/index.ts index f2d0032..6a2673d 100644 --- a/src/store/modules/auth/index.ts +++ b/src/store/modules/auth/index.ts @@ -78,15 +78,13 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => { const lastLoginUserId = localStg.get('lastLoginUserId'); // Clear all tabs if current user is different from previous user - if (!lastLoginUserId || lastLoginUserId !== userInfo.userId) { + if (lastLoginUserId !== userInfo.userId) { localStg.remove('globalTabs'); tabStore.clearTabs(); - localStg.remove('lastLoginUserId'); return true; } - localStg.remove('lastLoginUserId'); return false; }