From 5828ad55a178f35b67ab1d92b55a4a47ddb790cd Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Fri, 8 Apr 2022 11:35:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E4=BC=A0component=E7=BB=84=E4=BB=B6=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/components/setting/index.vue | 3 ++- src/layout/components/sidebar/horizontal.vue | 7 ------- src/layout/components/sidebar/vertical.vue | 1 - src/router/utils.ts | 6 +++++- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/layout/components/setting/index.vue b/src/layout/components/setting/index.vue index 45480f971..b51285360 100644 --- a/src/layout/components/setting/index.vue +++ b/src/layout/components/setting/index.vue @@ -266,6 +266,7 @@ function setLayoutThemeColor(theme: string) { // 设置ep主题色 const setEpThemeColor = (color: string) => { + // @ts-expect-error writeNewStyle(createNewStyle(color)); useEpThemeStoreHook().setEpThemeColor(color); body.style.setProperty("--el-color-primary-active", shadeBgColor(color)); @@ -298,7 +299,7 @@ nextTick(() => { settings.weakVal && document.querySelector("html")?.setAttribute("class", "html-weakness"); settings.tabsVal && tagsChange(); - + // @ts-expect-error writeNewStyle(createNewStyle(epThemeColor.value)); dataThemeChange(); }); diff --git a/src/layout/components/sidebar/horizontal.vue b/src/layout/components/sidebar/horizontal.vue index ed6649957..d2a414c7a 100644 --- a/src/layout/components/sidebar/horizontal.vue +++ b/src/layout/components/sidebar/horizontal.vue @@ -46,13 +46,6 @@ watch( } ); -watch( - () => route.path, - () => { - menuSelect(route.path, routers); - } -); - function translationCh() { instance.locale = { locale: "zh" }; locale.value = "zh"; diff --git a/src/layout/components/sidebar/vertical.vue b/src/layout/components/sidebar/vertical.vue index 94b81085c..bdef950a2 100644 --- a/src/layout/components/sidebar/vertical.vue +++ b/src/layout/components/sidebar/vertical.vue @@ -51,7 +51,6 @@ watch( () => route.path, () => { getSubMenuData(route.path); - menuSelect(route.path, routers); } ); diff --git a/src/router/utils.ts b/src/router/utils.ts index 9ad5ffdca..484fab2bf 100644 --- a/src/router/utils.ts +++ b/src/router/utils.ts @@ -234,7 +234,11 @@ function addAsyncRoutes(arrRoutes: Array) { } else if (v.meta?.frameSrc) { v.component = IFrame; } else { - const index = modulesRoutesKeys.findIndex(ev => ev.includes(v.path)); + // 对后端传component组件路径和不传做兼容(如果后端传component组件路径,那么path可以随便写,如果不传,component组件路径会根path保持一致) + const index = v?.component + ? // @ts-expect-error + modulesRoutesKeys.findIndex(ev => ev.includes(v.component)) + : modulesRoutesKeys.findIndex(ev => ev.includes(v.path)); v.component = modulesRoutes[modulesRoutesKeys[index]]; } if (v.children) {