Skip to content

Commit

Permalink
fix(projects): fix reCacheRoute. fixed #464
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Jun 1, 2024
1 parent 5bd96b8 commit 59faf15
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/store/modules/route/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,19 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
/** Cache routes */
const cacheRoutes = ref<RouteKey[]>([]);

/** All cache routes */
const allCacheRoutes = shallowRef<RouteKey[]>([]);

/**
* 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];
}

/**
Expand All @@ -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();
Expand Down

0 comments on commit 59faf15

Please sign in to comment.