Skip to content

Commit

Permalink
fix: remove redirect (alibaba#706)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenbin92 authored and noyobo committed Jul 13, 2018
1 parent 50289c7 commit 718251b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@icedesign/ice-design-dashboard",
"version": "1.0.1",
"version": "1.0.2",
"description": "该模板适用于简单的数据概览类展示,搭配简洁的暗色主题风格和图表类展示",
"homepage": "https://alibaba.github.io/ice/scaffold-preview/ice-design-dashboard.html",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,7 @@ export default class Aside extends Component {
this.state = {};
}

/**
* 当前展开的菜单项
*/
getOpenKeys = () => {
const { match } = this.props;
const matched = match.path;
let openKeys = [];

Array.isArray(asideMenuConfig) &&
asideMenuConfig.forEach((item, index) => {
if (matched.startsWith(item.path)) {
openKeys = [`${index}`];
}
});

return openKeys;
};

/**
* 点击菜单项触发的事件,模板默认点击菜单都跳转首页
* 实际业务开发按需处理
*/
onMenuClick = (selectedKeys) => {
if (selectedKeys !== '/') {
this.props.history.push('/');
}
};

render() {
const { location } = this.props;
const { pathname } = location;

return (
<div className="aside-content">
<Logo style={{ marginBottom: '10px' }} />
Expand All @@ -65,9 +34,7 @@ export default class Aside extends Component {
<Menu
style={{ width: 200 }}
onClick={this.onMenuClick}
selectedKeys={[pathname]}
defaultSelectedKeys={[pathname]}
defaultOpenKeys={[`${this.getOpenKeys()}`]}
defaultSelectedKeys={['0']}
mode="inline"
>
{asideMenuConfig &&
Expand All @@ -76,7 +43,7 @@ export default class Aside extends Component {
if (nav.children && nav.children.length > 0) {
return (
<SubMenu key={index} title={<span>{nav.name}</span>}>
{nav.children.map((item) => {
{nav.children.map((item, idx) => {
const linkProps = {};
if (item.newWindow) {
linkProps.href = item.path;
Expand All @@ -87,7 +54,7 @@ export default class Aside extends Component {
linkProps.to = item.path;
}
return (
<MenuItem key={item.path}>
<MenuItem key={idx}>
<Link {...linkProps}>{item.name}</Link>
</MenuItem>
);
Expand All @@ -105,7 +72,7 @@ export default class Aside extends Component {
linkProps.to = nav.path;
}
return (
<MenuItem key={nav.path}>
<MenuItem key={index}>
<Link {...linkProps}>
<span>{nav.name}</span>
</Link>
Expand Down
14 changes: 7 additions & 7 deletions react-materials/scaffolds/ice-design-dashboard/src/menuConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ const asideMenuConfig = [
},
{
name: 'invoices',
path: '/iceworks',
path: '/',
},
{
name: 'clients',
path: '/clients',
path: '/',
},
{
name: 'payments',
path: '/payments',
path: '/',
},
{
name: 'profile',
path: '/profile',
path: '/',
},
{
name: 'notifications',
path: '/notifications',
path: '/',
},
{
name: 'settings',
path: '/settings',
path: '/',
},
{
name: 'contact us',
path: '/contact',
path: '/',
},
];

Expand Down

0 comments on commit 718251b

Please sign in to comment.