From 8c31ca1bad8e1567030a5737efcc81403f753f1f Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Fri, 26 Nov 2021 22:54:29 +0800 Subject: [PATCH] fix: update name --- public/serverConfig.json | 2 +- src/layout/components/tag/index.vue | 28 ++++++++++++++-------------- src/layout/types.ts | 2 +- src/store/modules/multiTabs.ts | 20 -------------------- src/store/modules/multiTags.ts | 21 +++++++++++++++++++++ types/global.d.ts | 2 +- 6 files changed, 38 insertions(+), 37 deletions(-) delete mode 100644 src/store/modules/multiTabs.ts create mode 100644 src/store/modules/multiTags.ts diff --git a/public/serverConfig.json b/public/serverConfig.json index a7353fa56..7d28a5b06 100644 --- a/public/serverConfig.json +++ b/public/serverConfig.json @@ -3,7 +3,7 @@ "Title": "PureAdmin", "FixedHeader": true, "HiddenSideBar": false, - "MultiTabsCache": false, + "MultiTagsCache": false, "KeepAlive": true, "Locale": "zh", "Layout": "vertical", diff --git a/src/layout/components/tag/index.vue b/src/layout/components/tag/index.vue index a7e358bd7..067d41793 100644 --- a/src/layout/components/tag/index.vue +++ b/src/layout/components/tag/index.vue @@ -41,7 +41,7 @@ import { handleAliveRoute, delAliveRoutes } from "/@/router"; import { useSettingStoreHook } from "/@/store/modules/settings"; import { usePermissionStoreHook } from "/@/store/modules/permission"; import { toggleClass, removeClass, hasClass } from "/@/utils/operate"; -import { RouteConfigs, relativeStorageType, tagsViewsType } from "../../types"; +import { RouteConfigs, multiTagsType, tagsViewsType } from "../../types"; const route = useRoute(); const router = useRouter(); @@ -49,7 +49,7 @@ const translateX = ref(0); const activeIndex = ref(-1); let refreshButton = "refresh-button"; const instance = getCurrentInstance(); -let relativeStorage: relativeStorageType; +let multiTags: multiTagsType; const pureSetting = useSettingStoreHook(); const showTags = ref(storageLocal.getItem("tagsVal") || false); const tabDom = templateRef("tabDom", null); @@ -183,7 +183,7 @@ const tagsViews = ref>([ } ]); const dynamicTagList: ComputedRef> = computed(() => { - return relativeStorage.routesInStorage; + return multiTags.routesInStorage; }); // 显示模式,默认灵动模式显示 @@ -200,7 +200,7 @@ let buttonTop = ref(0); let currentSelect = ref({}); function dynamicRouteTag(value: string, parentPath: string): void { - const hasValue = relativeStorage.routesInStorage.some((item: any) => { + const hasValue = multiTags.routesInStorage.some((item: any) => { return item.path === value; }); @@ -215,7 +215,7 @@ function dynamicRouteTag(value: string, parentPath: string): void { meta: arrItem.meta, name: arrItem.name }); - relativeStorage.routesInStorage = routerArrays; + multiTags.routesInStorage = routerArrays; } else { if (arrItem.children && arrItem.children.length > 0) { concatPath(arrItem.children, value, parentPath); @@ -248,7 +248,7 @@ function deleteDynamicTag(obj: any, current: any, tag?: string) { const spliceRoute = (start?: number, end?: number, other?: boolean): void => { if (other) { - relativeStorage.routesInStorage = [ + multiTags.routesInStorage = [ { path: "/welcome", parentPath: "/", @@ -261,10 +261,10 @@ function deleteDynamicTag(obj: any, current: any, tag?: string) { }, obj ]; - routerArrays = relativeStorage.routesInStorage; + routerArrays = multiTags.routesInStorage; } else { delAliveRouteList = routerArrays.splice(start, end); - relativeStorage.routesInStorage = routerArrays; + multiTags.routesInStorage = routerArrays; } }; @@ -366,7 +366,7 @@ function onClickDrop(key, item, selectRoute?: RouteConfigs) { case 5: // 关闭全部标签页 routerArrays.splice(1, routerArrays.length); - relativeStorage.routesInStorage = routerArrays; + multiTags.routesInStorage = routerArrays; usePermissionStoreHook().clearAllCachePage(); router.push("/welcome"); @@ -400,8 +400,8 @@ function disabledMenus(value: boolean) { // 检查当前右键的菜单两边是否存在别的菜单,如果左侧的菜单是首页,则不显示关闭左侧标签页,如果右侧没有菜单,则不显示关闭右侧标签页 function showMenuModel(currentPath: string, refresh = false) { - let allRoute = unref(relativeStorage.routesInStorage); - let routeLength = unref(relativeStorage.routesInStorage).length; + let allRoute = unref(multiTags.routesInStorage); + let routeLength = unref(multiTags.routesInStorage).length; // currentIndex为1时,左侧的菜单是首页,则不显示关闭左侧标签页 let currentIndex = allRoute.findIndex(v => v.path === currentPath); // 如果currentIndex等于routeLength-1,右侧没有菜单,则不显示关闭右侧标签页 @@ -452,7 +452,7 @@ function openMenu(tag, e) { showMenuModel(tag.path); } else if ( // eslint-disable-next-line no-dupe-else-if - relativeStorage.routesInStorage.length === 2 && + multiTags.routesInStorage.length === 2 && route.path !== tag.path ) { showMenus(true); @@ -531,8 +531,8 @@ watch( onBeforeMount(() => { if (!instance) return; - relativeStorage = instance.appContext.app.config.globalProperties.$storage; - routerArrays = relativeStorage.routesInStorage ?? routerArrays; + multiTags = instance.appContext.app.config.globalProperties.$storage; + routerArrays = multiTags.routesInStorage ?? routerArrays; // 根据当前路由初始化操作标签页的禁用状态 showMenuModel(route.fullPath); diff --git a/src/layout/types.ts b/src/layout/types.ts index 5cf452bfb..3a991bdf5 100644 --- a/src/layout/types.ts +++ b/src/layout/types.ts @@ -24,7 +24,7 @@ export type RouteConfigs = { name?: string; }; -export type relativeStorageType = { +export type multiTagsType = { routesInStorage: Array; }; diff --git a/src/store/modules/multiTabs.ts b/src/store/modules/multiTabs.ts deleted file mode 100644 index 6c106e67e..000000000 --- a/src/store/modules/multiTabs.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { defineStore } from "pinia"; -import { store } from "/@/store"; -import { getConfig } from "/@/config"; - -export const useMultiTabsStore = defineStore({ - id: "pure-multiTabs", - state: () => ({ - multiTabsCache: getConfig().MultiTabsCache - }), - getters: { - getMultiTabsCache() { - return this.multiTabsCache; - } - }, - actions: {} -}); - -export function useMultiTabsStoreHook() { - return useMultiTabsStore(store); -} diff --git a/src/store/modules/multiTags.ts b/src/store/modules/multiTags.ts new file mode 100644 index 000000000..d03907d23 --- /dev/null +++ b/src/store/modules/multiTags.ts @@ -0,0 +1,21 @@ +import { defineStore } from "pinia"; +import { store } from "/@/store"; +import { getConfig } from "/@/config"; +// import { multiTagsType } from "/@/layout/types"; + +export const useMultiTagsStore = defineStore({ + id: "pure-multiTags", + state: () => ({ + multiTagsCache: getConfig().MultiTagsCache + }), + getters: { + getMultiTagsCache() { + return this.multiTagsCache; + } + }, + actions: {} +}); + +export function useMultiTagsStoreHook() { + return useMultiTagsStore(store); +} diff --git a/types/global.d.ts b/types/global.d.ts index c7f52b2e3..0f11db653 100644 --- a/types/global.d.ts +++ b/types/global.d.ts @@ -87,7 +87,7 @@ declare global { Title?: string; FixedHeader?: boolean; HiddenSideBar?: boolean; - MultiTabsCache?: boolean; + MultiTagsCache?: boolean; KeepAlive?: boolean; Locale?: string; Layout?: string;