调整页面跳转后缓存问题

This commit is contained in:
Ledo 2025-08-21 14:25:45 +08:00
parent f7b2b96466
commit b8dcd6d572
2 changed files with 6 additions and 4 deletions

View File

@ -58,16 +58,17 @@ export const useTagsViewStore = defineStore('tagsView', {
}, },
// 删除某个 // 删除某个
delView(view: RouteLocationNormalizedLoaded) { delView(view: RouteLocationNormalizedLoaded) {
routeParamsCache.remove(view.path)
this.delVisitedView(view) this.delVisitedView(view)
this.delCachedView() this.delCachedView()
routeParamsCache.remove(view.path)
}, },
// 删除tag // 删除tag
delVisitedView(view: RouteLocationNormalizedLoaded) { delVisitedView(view: RouteLocationNormalizedLoaded) {
for (const [i, v] of this.visitedViews.entries()) { for (const [i, v] of this.visitedViews.entries()) {
if (v.path === view.path) { if (v.path === view.path) {
routeParamsCache.remove(view.path)
this.visitedViews.splice(i, 1) this.visitedViews.splice(i, 1)
routeParamsCache.remove(view.path)
break break
} }
} }
@ -116,7 +117,7 @@ export const useTagsViewStore = defineStore('tagsView', {
) )
if (index > -1) { if (index > -1) {
this.visitedViews.filter((item,i) =>{ this.visitedViews.filter((item,i) =>{
if(i < index && v.path !== view.path ){ if(i < index && item.path !== view.path ){
routeParamsCache.remove(item.path) routeParamsCache.remove(item.path)
} }
}) })
@ -134,7 +135,7 @@ export const useTagsViewStore = defineStore('tagsView', {
) )
if (index > -1) { if (index > -1) {
this.visitedViews.filter((item,i) =>{ this.visitedViews.filter((item,i) =>{
if(i > index && v.path !== view.path ){ if(i > index && item.path !== view.path ){
routeParamsCache.remove(item.path) routeParamsCache.remove(item.path)
} }
}) })

View File

@ -83,6 +83,7 @@ const routeParamsCache = {
remove(route: String) { remove(route: String) {
const path = getCacheKey(route); const path = getCacheKey(route);
if (this.cache.has(path)) { if (this.cache.has(path)) {
this.cache.delete(path); this.cache.delete(path);
saveCache(this.cache); saveCache(this.cache);
return true; return true;