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;