From 023984875f8fcedd84e5f8fd7695b6aa127256e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Tue, 9 Oct 2018 15:31:51 +0800 Subject: [PATCH] fix #2488, add matchParamsPath default value --- package.json | 2 +- src/layouts/BasicLayout.js | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 784610a7..840d1f36 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "stylelint-config-standard": "^18.0.0", "umi": "^2.1.1", "umi-plugin-react": "^1.1.1", - "umi-plugin-ga": "^1.1.2" + "umi-plugin-ga": "^1.1.3" }, "optionalDependencies": { "puppeteer": "^1.9.0" diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index df33f326..ea849599 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -21,7 +21,7 @@ import Exception403 from '../pages/Exception/403'; const { Content } = Layout; // Conversion router to menu. -function formatter(data, parentPath = '', parentAuthority, parentName) { +function formatter(data, parentAuthority, parentName) { return data .map(item => { let locale = 'menu'; @@ -39,12 +39,7 @@ function formatter(data, parentPath = '', parentAuthority, parentName) { authority: item.authority || parentAuthority, }; if (item.routes) { - const children = formatter( - item.routes, - `${parentPath}${item.path}/`, - item.authority, - locale - ); + const children = formatter(item.routes, item.authority, locale); // Reduce memory usage result.children = children; } @@ -176,7 +171,7 @@ class BasicLayout extends React.PureComponent { const pathKey = Object.keys(this.breadcrumbNameMap).find(key => pathToRegexp(key).test(pathname) ); - return this.breadcrumbNameMap[pathKey]; + return this.breadcrumbNameMap[pathKey] || {}; }; getPageTitle = pathname => { -- GitLab