From 4c6acc91abe38b7d908b9206b06a5d1b21bfc10d Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Mon, 18 Jul 2022 13:48:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=B7=AF=E7=94=B1`sho?= =?UTF-8?q?wlink`=E4=B8=BA`false`=E7=9A=84=E5=BC=82=E6=AD=A5=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=EF=BC=8C=E5=88=B7=E6=96=B0=E5=90=8E=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/utils.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/router/utils.ts b/src/router/utils.ts index 6b2273385..1d25dc51b 100644 --- a/src/router/utils.ts +++ b/src/router/utils.ts @@ -8,6 +8,7 @@ import { } from "vue-router"; import { router } from "./index"; import { loadEnv } from "../../build"; +import { cloneDeep } from "lodash-unified"; import { useTimeoutFn } from "@vueuse/core"; import { RouteConfigs } from "/@/layout/types"; import { buildHierarchyTree } from "@pureadmin/utils"; @@ -39,7 +40,7 @@ function ascending(arr: any[]) { // 过滤meta中showLink为false的路由 function filterTree(data: RouteComponent[]) { - const newTree = data.filter( + const newTree = cloneDeep(data).filter( (v: { meta: { showLink: boolean } }) => v.meta?.showLink !== false ); newTree.forEach( @@ -135,7 +136,7 @@ function initRouter(name: string) { // 最终路由进行升序 ascending(router.options.routes[0].children); if (!router.hasRoute(v?.name)) router.addRoute(v); - const flattenRouters = router + const flattenRouters: any = router .getRoutes() .find(n => n.path === "/"); router.addRoute(flattenRouters);