fix: update name

This commit is contained in:
xiaoxian521
2021-11-26 22:54:29 +08:00
parent aca6a667f3
commit 8c31ca1bad
6 changed files with 38 additions and 37 deletions

View File

@@ -3,7 +3,7 @@
"Title": "PureAdmin", "Title": "PureAdmin",
"FixedHeader": true, "FixedHeader": true,
"HiddenSideBar": false, "HiddenSideBar": false,
"MultiTabsCache": false, "MultiTagsCache": false,
"KeepAlive": true, "KeepAlive": true,
"Locale": "zh", "Locale": "zh",
"Layout": "vertical", "Layout": "vertical",

View File

@@ -41,7 +41,7 @@ import { handleAliveRoute, delAliveRoutes } from "/@/router";
import { useSettingStoreHook } from "/@/store/modules/settings"; import { useSettingStoreHook } from "/@/store/modules/settings";
import { usePermissionStoreHook } from "/@/store/modules/permission"; import { usePermissionStoreHook } from "/@/store/modules/permission";
import { toggleClass, removeClass, hasClass } from "/@/utils/operate"; import { toggleClass, removeClass, hasClass } from "/@/utils/operate";
import { RouteConfigs, relativeStorageType, tagsViewsType } from "../../types"; import { RouteConfigs, multiTagsType, tagsViewsType } from "../../types";
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
@@ -49,7 +49,7 @@ const translateX = ref<number>(0);
const activeIndex = ref<number>(-1); const activeIndex = ref<number>(-1);
let refreshButton = "refresh-button"; let refreshButton = "refresh-button";
const instance = getCurrentInstance(); const instance = getCurrentInstance();
let relativeStorage: relativeStorageType; let multiTags: multiTagsType;
const pureSetting = useSettingStoreHook(); const pureSetting = useSettingStoreHook();
const showTags = ref(storageLocal.getItem("tagsVal") || false); const showTags = ref(storageLocal.getItem("tagsVal") || false);
const tabDom = templateRef<HTMLElement | null>("tabDom", null); const tabDom = templateRef<HTMLElement | null>("tabDom", null);
@@ -183,7 +183,7 @@ const tagsViews = ref<Array<tagsViewsType>>([
} }
]); ]);
const dynamicTagList: ComputedRef<Array<RouteConfigs>> = computed(() => { const dynamicTagList: ComputedRef<Array<RouteConfigs>> = computed(() => {
return relativeStorage.routesInStorage; return multiTags.routesInStorage;
}); });
// 显示模式,默认灵动模式显示 // 显示模式,默认灵动模式显示
@@ -200,7 +200,7 @@ let buttonTop = ref(0);
let currentSelect = ref({}); let currentSelect = ref({});
function dynamicRouteTag(value: string, parentPath: string): void { 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; return item.path === value;
}); });
@@ -215,7 +215,7 @@ function dynamicRouteTag(value: string, parentPath: string): void {
meta: arrItem.meta, meta: arrItem.meta,
name: arrItem.name name: arrItem.name
}); });
relativeStorage.routesInStorage = routerArrays; multiTags.routesInStorage = routerArrays;
} else { } else {
if (arrItem.children && arrItem.children.length > 0) { if (arrItem.children && arrItem.children.length > 0) {
concatPath(arrItem.children, value, parentPath); 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 => { const spliceRoute = (start?: number, end?: number, other?: boolean): void => {
if (other) { if (other) {
relativeStorage.routesInStorage = [ multiTags.routesInStorage = [
{ {
path: "/welcome", path: "/welcome",
parentPath: "/", parentPath: "/",
@@ -261,10 +261,10 @@ function deleteDynamicTag(obj: any, current: any, tag?: string) {
}, },
obj obj
]; ];
routerArrays = relativeStorage.routesInStorage; routerArrays = multiTags.routesInStorage;
} else { } else {
delAliveRouteList = routerArrays.splice(start, end); delAliveRouteList = routerArrays.splice(start, end);
relativeStorage.routesInStorage = routerArrays; multiTags.routesInStorage = routerArrays;
} }
}; };
@@ -366,7 +366,7 @@ function onClickDrop(key, item, selectRoute?: RouteConfigs) {
case 5: case 5:
// 关闭全部标签页 // 关闭全部标签页
routerArrays.splice(1, routerArrays.length); routerArrays.splice(1, routerArrays.length);
relativeStorage.routesInStorage = routerArrays; multiTags.routesInStorage = routerArrays;
usePermissionStoreHook().clearAllCachePage(); usePermissionStoreHook().clearAllCachePage();
router.push("/welcome"); router.push("/welcome");
@@ -400,8 +400,8 @@ function disabledMenus(value: boolean) {
// 检查当前右键的菜单两边是否存在别的菜单,如果左侧的菜单是首页,则不显示关闭左侧标签页,如果右侧没有菜单,则不显示关闭右侧标签页 // 检查当前右键的菜单两边是否存在别的菜单,如果左侧的菜单是首页,则不显示关闭左侧标签页,如果右侧没有菜单,则不显示关闭右侧标签页
function showMenuModel(currentPath: string, refresh = false) { function showMenuModel(currentPath: string, refresh = false) {
let allRoute = unref(relativeStorage.routesInStorage); let allRoute = unref(multiTags.routesInStorage);
let routeLength = unref(relativeStorage.routesInStorage).length; let routeLength = unref(multiTags.routesInStorage).length;
// currentIndex为1时左侧的菜单是首页则不显示关闭左侧标签页 // currentIndex为1时左侧的菜单是首页则不显示关闭左侧标签页
let currentIndex = allRoute.findIndex(v => v.path === currentPath); let currentIndex = allRoute.findIndex(v => v.path === currentPath);
// 如果currentIndex等于routeLength-1右侧没有菜单则不显示关闭右侧标签页 // 如果currentIndex等于routeLength-1右侧没有菜单则不显示关闭右侧标签页
@@ -452,7 +452,7 @@ function openMenu(tag, e) {
showMenuModel(tag.path); showMenuModel(tag.path);
} else if ( } else if (
// eslint-disable-next-line no-dupe-else-if // eslint-disable-next-line no-dupe-else-if
relativeStorage.routesInStorage.length === 2 && multiTags.routesInStorage.length === 2 &&
route.path !== tag.path route.path !== tag.path
) { ) {
showMenus(true); showMenus(true);
@@ -531,8 +531,8 @@ watch(
onBeforeMount(() => { onBeforeMount(() => {
if (!instance) return; if (!instance) return;
relativeStorage = instance.appContext.app.config.globalProperties.$storage; multiTags = instance.appContext.app.config.globalProperties.$storage;
routerArrays = relativeStorage.routesInStorage ?? routerArrays; routerArrays = multiTags.routesInStorage ?? routerArrays;
// 根据当前路由初始化操作标签页的禁用状态 // 根据当前路由初始化操作标签页的禁用状态
showMenuModel(route.fullPath); showMenuModel(route.fullPath);

View File

@@ -24,7 +24,7 @@ export type RouteConfigs = {
name?: string; name?: string;
}; };
export type relativeStorageType = { export type multiTagsType = {
routesInStorage: Array<RouteConfigs>; routesInStorage: Array<RouteConfigs>;
}; };

View File

@@ -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);
}

View File

@@ -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);
}

2
types/global.d.ts vendored
View File

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