Skip to content

Commit 59faf15

Browse files
committed
fix(projects): fix reCacheRoute. fixed #464
1 parent 5bd96b8 commit 59faf15

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/store/modules/route/index.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,19 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
9797
/** Cache routes */
9898
const cacheRoutes = ref<RouteKey[]>([]);
9999

100+
/** All cache routes */
101+
const allCacheRoutes = shallowRef<RouteKey[]>([]);
102+
100103
/**
101104
* Get cache routes
102105
*
103106
* @param routes Vue routes
104107
*/
105108
function getCacheRoutes(routes: RouteRecordRaw[]) {
106-
cacheRoutes.value = getCacheRouteNames(routes);
109+
const alls = getCacheRouteNames(routes);
110+
111+
cacheRoutes.value = alls;
112+
allCacheRoutes.value = [...alls];
107113
}
108114

109115
/**
@@ -130,12 +136,23 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
130136
cacheRoutes.value.splice(index, 1);
131137
}
132138

139+
/**
140+
* Is cached route
141+
*
142+
* @param routeKey
143+
*/
144+
function isCachedRoute(routeKey: RouteKey) {
145+
return allCacheRoutes.value.includes(routeKey);
146+
}
147+
133148
/**
134149
* Re cache routes by route key
135150
*
136151
* @param routeKey
137152
*/
138153
async function reCacheRoutesByKey(routeKey: RouteKey) {
154+
if (!isCachedRoute(routeKey)) return;
155+
139156
removeCacheRoutes(routeKey);
140157

141158
await appStore.reloadPage();

0 commit comments

Comments
 (0)