Browse Source

chore: 路由信息 `showLink` 设置成 `false` 后,当前路由信息不添加到标签页

xiaoxian521 2 years ago
parent
commit
f47fe9f19d
2 changed files with 11 additions and 4 deletions
  1. 7 2
      src/layout/hooks/useTag.ts
  2. 4 2
      src/store/modules/multiTags.ts

+ 7 - 2
src/layout/hooks/useTag.ts

@@ -12,10 +12,15 @@ import { tagsViewsType } from "../types";
 import { useEventListener } from "@vueuse/core";
 import { useRoute, useRouter } from "vue-router";
 import { transformI18n, $t } from "@/plugins/i18n";
-import { isEqual, isBoolean } from "@pureadmin/utils";
 import { useSettingStoreHook } from "@/store/modules/settings";
 import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
-import { storageLocal, toggleClass, hasClass } from "@pureadmin/utils";
+import {
+  isEqual,
+  isBoolean,
+  storageLocal,
+  toggleClass,
+  hasClass
+} from "@pureadmin/utils";
 
 import Fullscreen from "@iconify-icons/ri/fullscreen-fill";
 import CloseAllTags from "@iconify-icons/ri/subtract-line";

+ 4 - 2
src/store/modules/multiTags.ts

@@ -1,9 +1,8 @@
 import { defineStore } from "pinia";
 import { store } from "@/store";
-import { isEqual } from "@pureadmin/utils";
 import { routerArrays } from "@/layout/types";
 import { multiType, positionType } from "./types";
-import { isUrl, storageLocal } from "@pureadmin/utils";
+import { isEqual, isBoolean, isUrl, storageLocal } from "@pureadmin/utils";
 
 export const useMultiTagsStore = defineStore({
   id: "pure-multiTags",
@@ -54,6 +53,9 @@ export const useMultiTagsStore = defineStore({
             if (isUrl(tagVal?.name)) return;
             // 如果title为空拒绝添加空信息到标签页
             if (tagVal?.meta?.title.length === 0) return;
+            // showLink:false 不添加到标签页
+            if (isBoolean(tagVal?.meta?.showLink) && !tagVal?.meta?.showLink)
+              return;
             const tagPath = tagVal.path;
             // 判断tag是否已存在
             const tagHasExits = this.multiTags.some(tag => {