diff --git a/src/store/modules/route/index.ts b/src/store/modules/route/index.ts index 4de30a36..1acaf69f 100644 --- a/src/store/modules/route/index.ts +++ b/src/store/modules/route/index.ts @@ -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); } } @@ -240,6 +243,9 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => { handleUpdateRootRouteRedirect(home); setIsInitAuthRoute(true); + } else { + // if fetch user routes failed, reset store + authStore.resetStore(); } }