|
|
|
@ -43,16 +43,14 @@ const Breadcrumb = React.createClass({
|
|
|
|
|
React.PropTypes.string,
|
|
|
|
|
React.PropTypes.element,
|
|
|
|
|
]),
|
|
|
|
|
router: React.PropTypes.object,
|
|
|
|
|
routes: React.PropTypes.array,
|
|
|
|
|
params: React.PropTypes.object
|
|
|
|
|
params: React.PropTypes.object,
|
|
|
|
|
},
|
|
|
|
|
render() {
|
|
|
|
|
let crumbs;
|
|
|
|
|
const { separator, prefixCls, router, routes, params, children } = this.props;
|
|
|
|
|
const ReactRouter = router;
|
|
|
|
|
if (routes && routes.length > 0 && ReactRouter) {
|
|
|
|
|
let Link = ReactRouter.Link;
|
|
|
|
|
const { separator, prefixCls, routes, params, children } = this.props;
|
|
|
|
|
if (routes && routes.length > 0) {
|
|
|
|
|
const paths = [];
|
|
|
|
|
crumbs = routes.map((route, i) => {
|
|
|
|
|
if (!route.breadcrumbName) {
|
|
|
|
|
return null;
|
|
|
|
@ -60,12 +58,18 @@ const Breadcrumb = React.createClass({
|
|
|
|
|
const name = route.breadcrumbName.replace(/\:(.*)/g, (replacement, key) => {
|
|
|
|
|
return params[key] || replacement;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let link;
|
|
|
|
|
const path = route.path.indexOf('/') === 0 ? route.path : ('/' + route.path);
|
|
|
|
|
let path = route.path.indexOf('/') === 0 ? route.path : ('/' + route.path);
|
|
|
|
|
Object.keys(params).forEach(key => {
|
|
|
|
|
path = path.replace(':' + key, params[key]);
|
|
|
|
|
});
|
|
|
|
|
paths.push(path);
|
|
|
|
|
|
|
|
|
|
if (i === routes.length - 1) {
|
|
|
|
|
link = <span>{name}</span>;
|
|
|
|
|
} else {
|
|
|
|
|
link = <Link to={path} params={params}>{name}</Link>;
|
|
|
|
|
link = <a href={'#' + paths.join('/')}>{name}</a>;
|
|
|
|
|
}
|
|
|
|
|
return <BreadcrumbItem separator={separator} key={name}>{link}</BreadcrumbItem>;
|
|
|
|
|
});
|
|
|
|
|