|  | @@ -4,6 +4,13 @@ import { getConfig } from "/@/config";
 | 
	
		
			
				|  |  |  import { positionType } from "./types";
 | 
	
		
			
				|  |  |  import { storageLocal } from "/@/utils/storage";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +interface Itag {
 | 
	
		
			
				|  |  | +  path: string;
 | 
	
		
			
				|  |  | +  parentPath: string;
 | 
	
		
			
				|  |  | +  name: string;
 | 
	
		
			
				|  |  | +  meta: any;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  export const useMultiTagsStore = defineStore({
 | 
	
		
			
				|  |  |    id: "pure-multiTags",
 | 
	
		
			
				|  |  |    state: () => ({
 | 
	
	
		
			
				|  | @@ -34,14 +41,44 @@ export const useMultiTagsStore = defineStore({
 | 
	
		
			
				|  |  |        this.getMultiTagsCache &&
 | 
	
		
			
				|  |  |          storageLocal.setItem("responsive-tags", multiTags);
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  | -    handleTags<T>(mode: string, value?: T, position?: positionType): any {
 | 
	
		
			
				|  |  | +    handleTags<T>(
 | 
	
		
			
				|  |  | +      mode: string,
 | 
	
		
			
				|  |  | +      value?: T | Itag,
 | 
	
		
			
				|  |  | +      position?: positionType
 | 
	
		
			
				|  |  | +    ): any {
 | 
	
		
			
				|  |  |        switch (mode) {
 | 
	
		
			
				|  |  |          case "equal":
 | 
	
		
			
				|  |  |            this.multiTags = value;
 | 
	
		
			
				|  |  |            break;
 | 
	
		
			
				|  |  |          case "push":
 | 
	
		
			
				|  |  | -          this.multiTags.push(value);
 | 
	
		
			
				|  |  | -          this.tagsCache(this.multiTags);
 | 
	
		
			
				|  |  | +          {
 | 
	
		
			
				|  |  | +            const tagVal = value as Itag;
 | 
	
		
			
				|  |  | +            // 判断tag是否已存在:
 | 
	
		
			
				|  |  | +            const tagHasExits = this.multiTags.some(tag => {
 | 
	
		
			
				|  |  | +              return tag.path === tagVal?.path;
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (tagHasExits) return;
 | 
	
		
			
				|  |  | +            const meta = tagVal?.meta;
 | 
	
		
			
				|  |  | +            const dynamicLevel = meta?.dynamicLevel ?? -1;
 | 
	
		
			
				|  |  | +            if (dynamicLevel > 0) {
 | 
	
		
			
				|  |  | +              // dynamicLevel动态路由可打开的数量
 | 
	
		
			
				|  |  | +              const realPath = meta?.realPath ?? "";
 | 
	
		
			
				|  |  | +              // 获取到已经打开的动态路由数, 判断是否大于dynamicLevel
 | 
	
		
			
				|  |  | +              if (
 | 
	
		
			
				|  |  | +                this.multiTags.filter(e => e.meta?.realPath ?? "" === realPath)
 | 
	
		
			
				|  |  | +                  .length >= dynamicLevel
 | 
	
		
			
				|  |  | +              ) {
 | 
	
		
			
				|  |  | +                // 关闭第一个
 | 
	
		
			
				|  |  | +                const index = this.multiTags.findIndex(
 | 
	
		
			
				|  |  | +                  item => item.meta?.realPath === realPath
 | 
	
		
			
				|  |  | +                );
 | 
	
		
			
				|  |  | +                index !== -1 && this.multiTags.splice(index, 1);
 | 
	
		
			
				|  |  | +              }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            this.multiTags.push(value);
 | 
	
		
			
				|  |  | +            this.tagsCache(this.multiTags);
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  |            break;
 | 
	
		
			
				|  |  |          case "splice":
 | 
	
		
			
				|  |  |            this.multiTags.splice(position?.startIndex, position?.length);
 |