diff --git a/src/store/modules/route/index.ts b/src/store/modules/route/index.ts index 1acaf69f9..d49b756ba 100644 --- a/src/store/modules/route/index.ts +++ b/src/store/modules/route/index.ts @@ -97,13 +97,19 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => { /** Cache routes */ const cacheRoutes = ref([]); + /** All cache routes */ + const allCacheRoutes = shallowRef([]); + /** * Get cache routes * * @param routes Vue routes */ function getCacheRoutes(routes: RouteRecordRaw[]) { - cacheRoutes.value = getCacheRouteNames(routes); + const alls = getCacheRouteNames(routes); + + cacheRoutes.value = alls; + allCacheRoutes.value = [...alls]; } /** @@ -130,12 +136,23 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => { cacheRoutes.value.splice(index, 1); } + /** + * Is cached route + * + * @param routeKey + */ + function isCachedRoute(routeKey: RouteKey) { + return allCacheRoutes.value.includes(routeKey); + } + /** * Re cache routes by route key * * @param routeKey */ async function reCacheRoutesByKey(routeKey: RouteKey) { + if (!isCachedRoute(routeKey)) return; + removeCacheRoutes(routeKey); await appStore.reloadPage();