Commit 9a34d47c authored by Reed Sun's avatar Reed Sun Committed by ddcat1115

Improve the display of bread crumbs (#1053)

* Improve the display of bread crumbs

* unuse template literals
parent 6225aa6d
...@@ -38,6 +38,25 @@ const getRedirect = (item) => { ...@@ -38,6 +38,25 @@ const getRedirect = (item) => {
}; };
getMenuData().forEach(getRedirect); getMenuData().forEach(getRedirect);
/**
* 获取面包屑映射
* @param {Object} menuData 菜单配置
* @param {Object} routerData 路由配置
*/
const getBreadcrumbNameMap = (menuData, routerData) => {
const result = {};
const childResult = {};
for (const i of menuData) {
if (!routerData[i.path]) {
result[i.path] = i;
}
if (i.children) {
Object.assign(childResult, getBreadcrumbNameMap(i.children, routerData));
}
}
return Object.assign({}, routerData, result, childResult);
};
const query = { const query = {
'screen-xs': { 'screen-xs': {
maxWidth: 575, maxWidth: 575,
...@@ -76,7 +95,7 @@ class BasicLayout extends React.PureComponent { ...@@ -76,7 +95,7 @@ class BasicLayout extends React.PureComponent {
const { location, routerData } = this.props; const { location, routerData } = this.props;
return { return {
location, location,
breadcrumbNameMap: routerData, breadcrumbNameMap: getBreadcrumbNameMap(getMenuData(), routerData),
}; };
} }
componentDidMount() { componentDidMount() {
......
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