feat: 添加全局配置MaxTagsLevel属性,可设置打开标签页最大数

This commit is contained in:
xiaoxian521 2024-04-16 19:34:57 +08:00
parent abd042afe8
commit d1d2bcaa11
3 changed files with 12 additions and 0 deletions

View File

@ -4,7 +4,9 @@ import {
store, store,
isUrl, isUrl,
isEqual, isEqual,
isNumber,
isBoolean, isBoolean,
getConfig,
defineStore, defineStore,
routerArrays, routerArrays,
storageLocal, storageLocal,
@ -112,6 +114,14 @@ export const useMultiTagsStore = defineStore({
} }
this.multiTags.push(value); this.multiTags.push(value);
this.tagsCache(this.multiTags); this.tagsCache(this.multiTags);
if (
getConfig()?.MaxTagsLevel &&
isNumber(getConfig().MaxTagsLevel)
) {
if (this.multiTags.length > getConfig().MaxTagsLevel) {
this.multiTags.splice(1, 1);
}
}
} }
break; break;
case "splice": case "splice":

View File

@ -12,6 +12,7 @@ export {
export { export {
isUrl, isUrl,
isEqual, isEqual,
isNumber,
debounce, debounce,
isBoolean, isBoolean,
getKeyList, getKeyList,

1
types/global.d.ts vendored
View File

@ -87,6 +87,7 @@ declare global {
FixedHeader?: boolean; FixedHeader?: boolean;
HiddenSideBar?: boolean; HiddenSideBar?: boolean;
MultiTagsCache?: boolean; MultiTagsCache?: boolean;
MaxTagsLevel?: number;
KeepAlive?: boolean; KeepAlive?: boolean;
Locale?: string; Locale?: string;
Layout?: string; Layout?: string;