From c8e90b4bd76843101ab52dcc78b3a3aec5b8d2b9 Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Tue, 12 Oct 2021 13:45:59 +0800 Subject: [PATCH] fix: showLink is false,children menu still showing --- src/store/modules/permission.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts index f295a7bec..063ab40bf 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -13,9 +13,17 @@ export const usePermissionStore = defineStore({ }), actions: { asyncActionRoutes(routes) { + const filterTree = data => { + const newTree = data.filter(v => v.meta.showLink); + newTree.forEach( + v => v.children && (v.children = filterTree(v.children)) + ); + return newTree; + }; + if (this.wholeRoutes.length > 0) return; - this.wholeRoutes = ascending(this.constantRoutes.concat(routes)).filter( - v => v.meta.showLink + this.wholeRoutes = filterTree( + ascending(this.constantRoutes.concat(routes)) ); const getButtonAuth = (arrRoutes: Array) => {