Commit 91e47a40 authored by yoyo837's avatar yoyo837 Committed by 偏右

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

parent eca8d34d
...@@ -204,7 +204,11 @@ export const getRouterData = app => { ...@@ -204,7 +204,11 @@ export const getRouterData = app => {
Object.keys(routerConfig).forEach(path => { Object.keys(routerConfig).forEach(path => {
// Regular match item name // Regular match item name
// eg. router /user/:id === /user/chen // 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 = {}; let menuItem = {};
// If menuKey is not empty // If menuKey is not empty
if (menuKey) { if (menuKey) {
...@@ -219,6 +223,7 @@ export const getRouterData = app => { ...@@ -219,6 +223,7 @@ export const getRouterData = app => {
name: router.name || menuItem.name, name: router.name || menuItem.name,
authority: router.authority || menuItem.authority, authority: router.authority || menuItem.authority,
hideInBreadcrumb: router.hideInBreadcrumb || menuItem.hideInBreadcrumb, hideInBreadcrumb: router.hideInBreadcrumb || menuItem.hideInBreadcrumb,
inherited,
}; };
routerData[path] = router; routerData[path] = router;
}); });
......
...@@ -101,6 +101,9 @@ export default class PageHeader extends PureComponent { ...@@ -101,6 +101,9 @@ export default class PageHeader extends PureComponent {
// Loop data mosaic routing // Loop data mosaic routing
const extraBreadcrumbItems = pathSnippets.map((url, index) => { const extraBreadcrumbItems = pathSnippets.map((url, index) => {
const currentBreadcrumb = getBreadcrumb(breadcrumbNameMap, url); const currentBreadcrumb = getBreadcrumb(breadcrumbNameMap, url);
if (currentBreadcrumb.inherited) {
return null;
}
const isLinkable = index !== pathSnippets.length - 1 && currentBreadcrumb.component; const isLinkable = index !== pathSnippets.length - 1 && currentBreadcrumb.component;
return currentBreadcrumb.name && !currentBreadcrumb.hideInBreadcrumb ? ( return currentBreadcrumb.name && !currentBreadcrumb.hideInBreadcrumb ? (
<Breadcrumb.Item key={url}> <Breadcrumb.Item key={url}>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment