From 76ba2e3e5b52578d13a45cd0acb2b3bf3aefc7b9 Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Mon, 18 Aug 2025 14:51:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=BA=86`keepAlive:=20true`=E7=9A=84=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=9C=A8=E5=88=9D=E6=AC=A1=E5=8A=A0=E8=BD=BD=E7=BC=93=E6=85=A2?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B=E5=87=BA=E7=8E=B0=E7=9A=84?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=BC=93=E5=AD=98=E5=A4=B1=E6=95=88=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E8=BE=83=E9=9A=BE=E5=A4=8D=E7=8E=B0?= =?UTF-8?q?=EF=BC=8C=E6=84=9F=E8=B0=A2=E5=8F=8D=E9=A6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/permission.ts | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts index 97bc7cd9b..b5e3b5dee 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -2,7 +2,6 @@ import { defineStore } from "pinia"; import { type cacheType, store, - debounce, ascending, getKeyList, filterTree, @@ -33,33 +32,35 @@ export const usePermissionStore = defineStore("pure-permission", { 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) { 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; } - /** 监听缓存页面是否存在于标签页,不存在则删除 */ - 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() {