Преглед на файлове

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

yoyo837 преди 7 години
родител
ревизия
91e47a403e
променени са 2 файла, в които са добавени 9 реда и са изтрити 1 реда
  1. 6 1
      src/common/router.js
  2. 3 0
      src/components/PageHeader/index.js

+ 6 - 1
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 - 0
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}>