Browse Source

修复 #1995 中 为了就近显示title而导致面包屑在未配置菜单的子路由时重复多次

pull/2050/head
yoyo837 8 years ago
committed by 偏右
parent
commit
91e47a403e
  1. 7
      src/common/router.js
  2. 3
      src/components/PageHeader/index.js

7
src/common/router.js

@ -204,7 +204,11 @@ export const getRouterData = app => {
Object.keys(routerConfig).forEach(path => {
// Regular match item name
// eg. router /user/:id === /user/chen
const menuKey = findMenuKey(menuData, path);
let menuKey = Object.keys(menuData).find(key => pathToRegexp(path).test(`${key}`));
const inherited = menuKey == null;
if (menuKey == null) {
menuKey = findMenuKey(menuData, path);
}
let menuItem = {};
// If menuKey is not empty
if (menuKey) {
@ -219,6 +223,7 @@ export const getRouterData = app => {
name: router.name || menuItem.name,
authority: router.authority || menuItem.authority,
hideInBreadcrumb: router.hideInBreadcrumb || menuItem.hideInBreadcrumb,
inherited,
};
routerData[path] = router;
});

3
src/components/PageHeader/index.js

@ -101,6 +101,9 @@ export default class PageHeader extends PureComponent {
// Loop data mosaic routing
const extraBreadcrumbItems = pathSnippets.map((url, index) => {
const currentBreadcrumb = getBreadcrumb(breadcrumbNameMap, url);
if (currentBreadcrumb.inherited) {
return null;
}
const isLinkable = index !== pathSnippets.length - 1 && currentBreadcrumb.component;
return currentBreadcrumb.name && !currentBreadcrumb.hideInBreadcrumb ? (
<Breadcrumb.Item key={url}>

Loading…
Cancel
Save