Просмотр исходного кода

feat: 重写proLayout的面包屑

lanjianrong 3 лет назад
Родитель
Сommit
056316847d
2 измененных файлов с 9 добавлено и 2 удалено
  1. 2 2
      package.json
  2. 7 0
      src/app.tsx

+ 2 - 2
package.json

@@ -51,11 +51,11 @@
     "@ant-design/icons": "^4.5.0",
     "@ant-design/pro-descriptions": "^1.6.8",
     "@ant-design/pro-form": "^1.18.3",
-    "@ant-design/pro-layout": "^6.15.3",
+    "@ant-design/pro-layout": "6.32.1",
     "@ant-design/pro-table": "^2.30.8",
     "@umijs/route-utils": "^1.0.36",
     "ahooks": "^3.0.0",
-    "antd": "^4.14.0",
+    "antd": "4.18.1",
     "classnames": "^2.2.6",
     "dayjs": "^1.10.7",
     "form-render": "1.7.3",

+ 7 - 0
src/app.tsx

@@ -2,6 +2,7 @@ import type { Settings as LayoutSettings } from '@ant-design/pro-layout'
 import { notification } from 'antd'
 import { PageLoading } from '@ant-design/pro-layout'
 import type { RequestConfig, RunTimeLayoutConfig } from 'umi'
+import { Link } from 'umi'
 import { getIntl, getLocale, history } from 'umi'
 import type { RequestOptionsInit, ResponseError } from 'umi-request'
 import RightContent from '@/components/RightContent'
@@ -182,6 +183,12 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => {
       // }
     },
     menuHeaderRender: undefined,
+    itemRender: (route, _, routes) => {
+      if (routes.indexOf(route) === routes.length - 1) {
+        return <span>{route.breadcrumbName}</span>
+      }
+      return <Link to={route.path}>{route.breadcrumbName}</Link>
+    },
     // 自定义 403 页面
     // unAccessible: <div>unAccessible</div>,
     ...initialState?.settings