From 6dc0a4a2a852808804a3dabd1b23b2e459642131 Mon Sep 17 00:00:00 2001 From: Fine Date: Mon, 10 Jul 2023 11:55:32 +0800 Subject: [PATCH] fix: update --- src/router/index.ts | 2 +- src/router/layer.ts | 4 +++- src/store/modules/app.ts | 13 +++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index 1a471de8..4fb334a8 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -30,7 +30,7 @@ const router = createRouter({ (window as any).axiosCancel = []; -const defaultPath = routesLayers[0].children[0].path; +const defaultPath = (routesLayers[0] && routesLayers[0].children[0].path) || ""; router.beforeEach((to, from, next) => { // const token = window.localStorage.getItem("skywalking-authority"); diff --git a/src/router/layer.ts b/src/router/layer.ts index 3ba8d334..3ab5cba6 100644 --- a/src/router/layer.ts +++ b/src/router/layer.ts @@ -25,8 +25,9 @@ async function layerDashboards() { path: "", component: Layout, meta: { - icon: item.icon, + icon: item.icon || "cloud_queue", title: item.title, + hasGroup: item.hasGroup, }, children: item.subItems && item.subItems.length ? [] : undefined, }; @@ -37,6 +38,7 @@ async function layerDashboards() { meta: { title: child.title, layer: child.layer, + icon: child.icon || "cloud_queue", }, }; d.component = () => import("@/views/Layer.vue"); diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts index 1204e264..df7a7557 100644 --- a/src/store/modules/app.ts +++ b/src/store/modules/app.ts @@ -172,17 +172,18 @@ export const appStore = defineStore({ ); }, async getActivateMenus() { + // localStorage.removeItem("customMenus"); const resp = (await this.queryMenuItems()) || {}; const menus = (resp.getMenuItems || []).map((d: MenuOptions, index: number) => { - const name = `${d.title.replace(/\s+/g, "-")}-${index}`; - d.name = name; - d.path = `/${name}`; + const t = `${d.title.replace(/\s+/g, "-")}`; + d.name = `${t}-${index}`; + d.path = `/${t}`; if (d.subItems && d.subItems.length) { d.hasGroup = true; d.subItems = d.subItems.map((item: any, sub: number) => { - const id = `${d.title.replace(/\s+/g, "-")}-${index}${sub}`; - item.name = id; - item.path = `/${id}`; + const id = `${item.title.replace(/\s+/g, "-")}`; + item.name = `${id}-${index}${sub}`; + item.path = `/${t}/${id}`; return item; }); } else {