File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff 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 ( ) ;
You can’t perform that action at this time.
0 commit comments