From d1d2bcaa114802e38529b803feec0a88dba2bc3b Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Tue, 16 Apr 2024 19:34:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E9=85=8D=E7=BD=AE`MaxTagsLevel`=E5=B1=9E=E6=80=A7=EF=BC=8C?= =?UTF-8?q?=E5=8F=AF=E8=AE=BE=E7=BD=AE=E6=89=93=E5=BC=80=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E9=A1=B5=E6=9C=80=E5=A4=A7=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/multiTags.ts | 10 ++++++++++ src/store/utils.ts | 1 + types/global.d.ts | 1 + 3 files changed, 12 insertions(+) diff --git a/src/store/modules/multiTags.ts b/src/store/modules/multiTags.ts index 3e8736766..fbcfd1d75 100644 --- a/src/store/modules/multiTags.ts +++ b/src/store/modules/multiTags.ts @@ -4,7 +4,9 @@ import { store, isUrl, isEqual, + isNumber, isBoolean, + getConfig, defineStore, routerArrays, storageLocal, @@ -112,6 +114,14 @@ export const useMultiTagsStore = defineStore({ } this.multiTags.push(value); this.tagsCache(this.multiTags); + if ( + getConfig()?.MaxTagsLevel && + isNumber(getConfig().MaxTagsLevel) + ) { + if (this.multiTags.length > getConfig().MaxTagsLevel) { + this.multiTags.splice(1, 1); + } + } } break; case "splice": diff --git a/src/store/utils.ts b/src/store/utils.ts index 7def7f2dd..581a43dca 100644 --- a/src/store/utils.ts +++ b/src/store/utils.ts @@ -12,6 +12,7 @@ export { export { isUrl, isEqual, + isNumber, debounce, isBoolean, getKeyList, diff --git a/types/global.d.ts b/types/global.d.ts index 087e5c719..28d720cc2 100644 --- a/types/global.d.ts +++ b/types/global.d.ts @@ -87,6 +87,7 @@ declare global { FixedHeader?: boolean; HiddenSideBar?: boolean; MultiTagsCache?: boolean; + MaxTagsLevel?: number; KeepAlive?: boolean; Locale?: string; Layout?: string;