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,21 +32,8 @@ export const usePermissionStore = defineStore("pure-permission", {
|
|||||||
this.constantMenus.concat(routes) as any
|
this.constantMenus.concat(routes) as any
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
cacheOperate({ mode, name }: cacheType) {
|
|
||||||
const delIndex = this.cachePageList.findIndex(v => v === name);
|
|
||||||
switch (mode) {
|
|
||||||
case "refresh":
|
|
||||||
this.cachePageList = this.cachePageList.filter(v => v !== name);
|
|
||||||
break;
|
|
||||||
case "add":
|
|
||||||
this.cachePageList.push(name);
|
|
||||||
break;
|
|
||||||
case "delete":
|
|
||||||
delIndex !== -1 && this.cachePageList.splice(delIndex, 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/** 监听缓存页面是否存在于标签页,不存在则删除 */
|
/** 监听缓存页面是否存在于标签页,不存在则删除 */
|
||||||
debounce(() => {
|
clearCache() {
|
||||||
let cacheLength = this.cachePageList.length;
|
let cacheLength = this.cachePageList.length;
|
||||||
const nameList = getKeyList(useMultiTagsStoreHook().multiTags, "name");
|
const nameList = getKeyList(useMultiTagsStoreHook().multiTags, "name");
|
||||||
while (cacheLength > 0) {
|
while (cacheLength > 0) {
|
||||||
@ -59,7 +45,22 @@ export const usePermissionStore = defineStore("pure-permission", {
|
|||||||
);
|
);
|
||||||
cacheLength--;
|
cacheLength--;
|
||||||
}
|
}
|
||||||
})();
|
},
|
||||||
|
cacheOperate({ mode, name }: cacheType) {
|
||||||
|
const delIndex = this.cachePageList.findIndex(v => v === name);
|
||||||
|
switch (mode) {
|
||||||
|
case "refresh":
|
||||||
|
this.cachePageList = this.cachePageList.filter(v => v !== name);
|
||||||
|
this.clearCache();
|
||||||
|
break;
|
||||||
|
case "add":
|
||||||
|
this.cachePageList.push(name);
|
||||||
|
break;
|
||||||
|
case "delete":
|
||||||
|
delIndex !== -1 && this.cachePageList.splice(delIndex, 1);
|
||||||
|
this.clearCache();
|
||||||
|
break;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
/** 清空缓存页面 */
|
/** 清空缓存页面 */
|
||||||
clearAllCachePage() {
|
clearAllCachePage() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user