提交 db5be199 authored 作者: vipcxj's avatar vipcxj

fix: 左侧菜单默认图标丢失

上级 539d440d
......@@ -36,6 +36,18 @@ const createMenu = async (configure) => {
return menu;
};
const makeIcon = (menu) => {
const children = menu.children;
if (!children || children.length === 0) {
menu.icon = 'file'; // eslint-disable-line no-param-reassign
} else {
menu.icon = 'folder'; // eslint-disable-line no-param-reassign
for (const child of children) {
makeIcon(child);
}
}
};
const createMenus = async (menusConfigure) => {
const menus = [];
if (menusConfigure) {
......@@ -43,6 +55,9 @@ const createMenus = async (menusConfigure) => {
menus.push(await createMenu(configure));
}
}
for (const menu of menus) {
makeIcon(menu);
}
return menus;
};
......
......@@ -19,17 +19,37 @@ export default [
{
name: 'group1',
showName: '测试组1',
children: [
{
name: 'group00',
showName: '测试组00',
modules: [{
name: 'test1',
showName: '测试模块1',
layout: {
route: 'task',
},
}],
},
],
modules: [
{
name: 'test1',
showName: '测试模块1',
name: 'test2',
showName: '测试模块2',
layout: {
route: 'task',
},
},
{
name: 'test2',
showName: '测试模块2',
name: 'test3',
showName: '测试模块3',
layout: {
route: 'task',
},
},
{
name: 'test4',
showName: '测试模块4',
layout: {
route: 'task',
},
......
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'dva';
import { routerRedux } from 'dva/router';
import { withRouter } from 'dva/router';
import { Layout } from 'antd';
import SiderLogo from '../../components/layout/sider/SiderLogo';
import SiderMenu from '../../components/layout/sider/SiderMenu';
import HeaderPane from './header';
import { fullPath } from '../../utils/helper';
import { thisPush } from '../../services/route';
import styles from './index.less';
const { Sider, Header, Content, Footer } = Layout;
......@@ -27,7 +27,8 @@ class Main extends React.Component {
}
onClick({ keyPath }) {
const paths = keyPath.reverse().join('/');
this.props.dispatch(routerRedux.push(fullPath(`/main/${paths}`)));
thisPush(this, `/main/${paths}`);
// this.props.dispatch(routerRedux.push(fullPath(`/main/${paths}`)));
}
onCollapse(collapsed) {
this.setState({
......@@ -78,4 +79,4 @@ Main.propTypes = {
main: PropTypes.object.isRequired,
};
export default connect(({ main }) => ({ main }))(Main);
export default connect(({ main }) => ({ main }))(withRouter(Main));
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论