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,
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":

View File

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

1
types/global.d.ts vendored
View File

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