mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-09-16 11:34:55 +08:00
fix: 修复设置了keepAlive: true
的页面在初次加载缓慢的情况下出现的页面缓存失效的问题,较难复现,感谢反馈
This commit is contained in:
parent
069131a9c8
commit
76ba2e3e5b
@ -2,7 +2,6 @@ import { defineStore } from "pinia";
|
|||||||
import {
|
import {
|
||||||
type cacheType,
|
type cacheType,
|
||||||
store,
|
store,
|
||||||
debounce,
|
|
||||||
ascending,
|
ascending,
|
||||||
getKeyList,
|
getKeyList,
|
||||||
filterTree,
|
filterTree,
|
||||||
@ -33,33 +32,35 @@ export const usePermissionStore = defineStore("pure-permission", {
|
|||||||
this.constantMenus.concat(routes) as any
|
this.constantMenus.concat(routes) as any
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
/** 监听缓存页面是否存在于标签页,不存在则删除 */
|
||||||
|
clearCache() {
|
||||||
|
let cacheLength = this.cachePageList.length;
|
||||||
|
const nameList = getKeyList(useMultiTagsStoreHook().multiTags, "name");
|
||||||
|
while (cacheLength > 0) {
|
||||||
|
nameList.findIndex(v => v === this.cachePageList[cacheLength - 1]) ===
|
||||||
|
-1 &&
|
||||||
|
this.cachePageList.splice(
|
||||||
|
this.cachePageList.indexOf(this.cachePageList[cacheLength - 1]),
|
||||||
|
1
|
||||||
|
);
|
||||||
|
cacheLength--;
|
||||||
|
}
|
||||||
|
},
|
||||||
cacheOperate({ mode, name }: cacheType) {
|
cacheOperate({ mode, name }: cacheType) {
|
||||||
const delIndex = this.cachePageList.findIndex(v => v === name);
|
const delIndex = this.cachePageList.findIndex(v => v === name);
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case "refresh":
|
case "refresh":
|
||||||
this.cachePageList = this.cachePageList.filter(v => v !== name);
|
this.cachePageList = this.cachePageList.filter(v => v !== name);
|
||||||
|
this.clearCache();
|
||||||
break;
|
break;
|
||||||
case "add":
|
case "add":
|
||||||
this.cachePageList.push(name);
|
this.cachePageList.push(name);
|
||||||
break;
|
break;
|
||||||
case "delete":
|
case "delete":
|
||||||
delIndex !== -1 && this.cachePageList.splice(delIndex, 1);
|
delIndex !== -1 && this.cachePageList.splice(delIndex, 1);
|
||||||
|
this.clearCache();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/** 监听缓存页面是否存在于标签页,不存在则删除 */
|
|
||||||
debounce(() => {
|
|
||||||
let cacheLength = this.cachePageList.length;
|
|
||||||
const nameList = getKeyList(useMultiTagsStoreHook().multiTags, "name");
|
|
||||||
while (cacheLength > 0) {
|
|
||||||
nameList.findIndex(v => v === this.cachePageList[cacheLength - 1]) ===
|
|
||||||
-1 &&
|
|
||||||
this.cachePageList.splice(
|
|
||||||
this.cachePageList.indexOf(this.cachePageList[cacheLength - 1]),
|
|
||||||
1
|
|
||||||
);
|
|
||||||
cacheLength--;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
},
|
},
|
||||||
/** 清空缓存页面 */
|
/** 清空缓存页面 */
|
||||||
clearAllCachePage() {
|
clearAllCachePage() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user