From 2efb726c3e13eb91245c8adf68d81684dfbe304c Mon Sep 17 00:00:00 2001 From: pengYYY Date: Tue, 22 Feb 2022 12:20:33 +0800 Subject: [PATCH] feat(router): add route hidden --- src/layouts/components/MenuContent.tsx | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/layouts/components/MenuContent.tsx b/src/layouts/components/MenuContent.tsx index 171f389..e70795f 100644 --- a/src/layouts/components/MenuContent.tsx +++ b/src/layouts/components/MenuContent.tsx @@ -6,17 +6,19 @@ const getMenuList = (list: MenuRoute[], basePath?: string): MenuRoute[] => { if (!list) { return []; } - return list.map((item) => { - const path = basePath ? `${basePath}/${item.path}` : item.path; - return { - path, - title: item.meta?.title, - icon: item.meta?.icon || '', - children: getMenuList(item.children, path), - meta: item.meta, - redirect: item.redirect, - }; - }); + return list + .map((item) => { + const path = basePath ? `${basePath}/${item.path}` : item.path; + return { + path, + title: item.meta?.title, + icon: item.meta?.icon || '', + children: getMenuList(item.children, path), + meta: item.meta, + redirect: item.redirect, + }; + }) + .filter((item) => item.meta && item.meta.hidden !== true); }; const renderIcon = (item) => {