diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index 9a0237bfcfd4a1878de191dda87a21b014b049e6..2e9ec908c8fd85214128f0f4de56b5a4c610fe48 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -55,8 +55,10 @@ class BasicLayout extends React.PureComponent { getChildContext() { const { location } = this.props; const routeData = getRouteData('BasicLayout'); - const menuData = getNavData().reduce((arr, current) => arr.concat(current.children), []); + const firstMenuData = getNavData().reduce((arr, current) => arr.concat(current.children), []); + const menuData = this.getMenuData(firstMenuData, ''); const breadcrumbNameMap = {}; + routeData.concat(menuData).forEach((item) => { breadcrumbNameMap[item.path] = item.name; }); @@ -83,6 +85,16 @@ class BasicLayout extends React.PureComponent { }); } } + getMenuData = (data, parentPath) => { + let arr = []; + data.forEach((item) => { + if (item.children) { + arr.push({ path: `${parentPath}/${item.path}`, name: item.name }); + arr = arr.concat(this.getMenuData(item.children, `${parentPath}/${item.path}`)); + } + }); + return arr; + } getDefaultCollapsedSubMenus(props) { const currentMenuSelectedKeys = [...this.getCurrentMenuSelectedKeys(props)]; currentMenuSelectedKeys.splice(-1, 1);