清除缓存新增批量清楚
This commit is contained in:
parent
b8dcd6d572
commit
0a2e4647e8
@ -60,18 +60,23 @@ export const useTagsViewStore = defineStore('tagsView', {
|
||||
delView(view: RouteLocationNormalizedLoaded) {
|
||||
this.delVisitedView(view)
|
||||
this.delCachedView()
|
||||
routeParamsCache.remove(view.path)
|
||||
setTimeout(() => {
|
||||
routeParamsCache.remove(view.path)
|
||||
}, 300)
|
||||
},
|
||||
// 删除tag
|
||||
delVisitedView(view: RouteLocationNormalizedLoaded) {
|
||||
const list = [];
|
||||
for (const [i, v] of this.visitedViews.entries()) {
|
||||
if (v.path === view.path) {
|
||||
|
||||
this.visitedViews.splice(i, 1)
|
||||
routeParamsCache.remove(view.path)
|
||||
list.push(view.path);
|
||||
break
|
||||
}
|
||||
}
|
||||
setTimeout(() => {
|
||||
routeParamsCache.removeBatch(list)
|
||||
}, 300)
|
||||
},
|
||||
// 删除缓存
|
||||
delCachedView() {
|
||||
|
@ -73,7 +73,6 @@ const routeParamsCache = {
|
||||
timestamp: Date.now(),
|
||||
};
|
||||
this.cache.set(path, cachedParams);
|
||||
saveCache(this.cache);
|
||||
},
|
||||
|
||||
get(route: String) {
|
||||
@ -90,7 +89,17 @@ const routeParamsCache = {
|
||||
}
|
||||
return false;
|
||||
},
|
||||
removeBatch(routeArrary: []) {
|
||||
routeArrary.forEach(route =>{
|
||||
const path = getCacheKey(route);
|
||||
if (this.cache.has(path)) {
|
||||
|
||||
this.cache.delete(path);
|
||||
saveCache(this.cache);
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
cleanExpired(expireHours = DEFAULT_EXPIRE_HOURS) {
|
||||
const now = Date.now();
|
||||
const expired = Array.from(this.cache.entries()).filter(
|
||||
|
Loading…
Reference in New Issue
Block a user