Skip to content

Commit

Permalink
fix(projects): add error handle when get routes in dynamic route mode…
Browse files Browse the repository at this point in the history
…. fixed 440
  • Loading branch information
honghuangdc committed May 19, 2024
1 parent 0774a51 commit 57b4a9d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/store/modules/route/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,18 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
async function initConstantRoute() {
if (isInitConstantRoute.value) return;

if (authRouteMode.value === 'static') {
const staticRoute = createStaticRoutes();
const staticRoute = createStaticRoutes();

if (authRouteMode.value === 'static') {
addConstantRoutes(staticRoute.constantRoutes);
} else {
const { data, error } = await fetchGetConstantRoutes();

if (!error) {
addConstantRoutes(data);
} else {
// if fetch constant routes failed, use static constant routes
addConstantRoutes(staticRoute.constantRoutes);
}
}

Expand Down Expand Up @@ -240,6 +243,9 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
handleUpdateRootRouteRedirect(home);

setIsInitAuthRoute(true);
} else {
// if fetch user routes failed, reset store
authStore.resetStore();
}
}

Expand Down

0 comments on commit 57b4a9d

Please sign in to comment.