Skip to content

Commit 0dfcf18

Browse files
committed
optimize(projects): optimize router guard
1 parent ba38119 commit 0dfcf18

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/router/guard/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ async function initRoute(to: RouteLocationNormalized): Promise<RouteLocationRaw
117117
return location;
118118
}
119119

120-
await routeStore.onRouteSwitchWhenLoggedIn();
121-
122120
if (!routeStore.isInitAuthRoute) {
123121
// initialize the auth route
124122
await routeStore.initAuthRoute();
@@ -140,6 +138,8 @@ async function initRoute(to: RouteLocationNormalized): Promise<RouteLocationRaw
140138
}
141139
}
142140

141+
routeStore.onRouteSwitchWhenLoggedIn();
142+
143143
// the auth route is initialized
144144
// it is not the "not-found" route, then it is allowed to access
145145
if (!isNotFoundRoute) {

src/store/modules/auth/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
6969
const pass = await loginByToken(loginToken);
7070

7171
if (pass) {
72-
await routeStore.initAuthRoute();
73-
7472
await redirectFromLogin(redirect);
7573

7674
if (routeStore.isInitAuthRoute) {

0 commit comments

Comments
 (0)