From 8f5ebb846c44f4b06e420438410d9964668ed36a Mon Sep 17 00:00:00 2001 From: chenos Date: Wed, 23 Dec 2020 20:12:50 +0800 Subject: [PATCH] fix: menu filter showInMenu=true --- packages/plugin-pages/src/actions/getRoutes.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/plugin-pages/src/actions/getRoutes.ts b/packages/plugin-pages/src/actions/getRoutes.ts index 8b9bbdc611..323815f33a 100644 --- a/packages/plugin-pages/src/actions/getRoutes.ts +++ b/packages/plugin-pages/src/actions/getRoutes.ts @@ -12,11 +12,15 @@ function pages2routes(pages: Array) { }; // page.type === 'layout' && if (!page.redirect && children.length) { - const items = children.sort((a, b) => a.sort - b.sort); - route.redirect = items[0].path; + const items = children.filter(item => item.showInMenu).sort((a, b) => a.sort - b.sort); + const redirect = get(items, [0, 'path']); + if (redirect) { + route.redirect = redirect; + } } if (page.type === 'layout' && children.length) { - route.menu = children.map(child => ({ + const items = children.filter(item => item.showInMenu).sort((a, b) => a.sort - b.sort); + route.menu = items.map(child => ({ ...child, title: child.title, path: child.path,