2017-07-28 17:30:56 +08:00
|
|
|
import './Breadcrumb.scss';
|
2017-10-25 19:33:34 +08:00
|
|
|
import {withRouter} from 'react-router-dom';
|
|
|
|
import {Breadcrumb} from 'antd';
|
2017-07-30 15:06:03 +08:00
|
|
|
import PropTypes from 'prop-types'
|
2017-10-25 19:33:34 +08:00
|
|
|
import React, {Component} from 'react';
|
|
|
|
import {connect} from 'react-redux';
|
|
|
|
import {Link} from 'react-router-dom'
|
2017-07-28 21:16:47 +08:00
|
|
|
|
2017-08-28 17:24:17 +08:00
|
|
|
@connect(
|
|
|
|
state => {
|
|
|
|
return {
|
|
|
|
breadcrumb: state.user.breadcrumb
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
2017-07-28 17:30:56 +08:00
|
|
|
@withRouter
|
|
|
|
export default class BreadcrumbNavigation extends Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2017-07-28 21:16:47 +08:00
|
|
|
}
|
2017-10-25 19:33:34 +08:00
|
|
|
|
2017-07-30 15:06:03 +08:00
|
|
|
static propTypes = {
|
2017-08-28 17:24:17 +08:00
|
|
|
breadcrumb: PropTypes.array
|
2017-07-30 15:06:03 +08:00
|
|
|
}
|
2017-10-25 19:33:34 +08:00
|
|
|
|
|
|
|
render() {
|
2017-08-28 17:24:17 +08:00
|
|
|
const getItem = this.props.breadcrumb.map((item, index) => {
|
2017-08-28 18:12:13 +08:00
|
|
|
if (item.href) {
|
2017-08-28 17:24:17 +08:00
|
|
|
return (<Breadcrumb.Item key={index}><Link to={item.href}>{item.name}</Link></Breadcrumb.Item>);
|
|
|
|
} else {
|
|
|
|
return (<Breadcrumb.Item key={index}>{item.name}</Breadcrumb.Item>);
|
2017-07-31 10:56:22 +08:00
|
|
|
}
|
2017-07-28 21:16:47 +08:00
|
|
|
})
|
2017-08-28 17:24:17 +08:00
|
|
|
return (<div className="breadcrumb-container">
|
|
|
|
<Breadcrumb>
|
|
|
|
{getItem}
|
|
|
|
</Breadcrumb>
|
|
|
|
</div>);
|
2017-07-28 17:30:56 +08:00
|
|
|
}
|
|
|
|
}
|