feat: 面包屑导航

This commit is contained in:
wenbo.dong 2017-07-31 11:16:36 +08:00
parent 14def380bb
commit e68998cda1
2 changed files with 14 additions and 5 deletions

View File

@ -6,7 +6,7 @@ import { Home, ProjectGroups, Interface, News, AddInterface } from './containers
import User from './containers/User/User.js';
import Header from './components/Header/Header';
import Footer from './components/Footer/Footer';
// import Breadcrumb from './components/Breadcrumb/Breadcrumb';
import Breadcrumb from './components/Breadcrumb/Breadcrumb';
import Loading from './components/Loading/Loading';
import { checkLoginState } from './actions/login';
import { requireAuthentication } from './components/AuthenticatedComponent';
@ -50,7 +50,7 @@ export default class App extends Component {
<div className="router-main">
<Header />
<div className="router-container">
{/* <Breadcrumb /> */}
<Breadcrumb />
<Route path="/" component={Home} exact />
<Switch>
<Redirect exact from='/group' to='/group/1' />

View File

@ -28,7 +28,7 @@ export default class BreadcrumbNavigation extends Component {
if (/project|group|add-interface/.test(pathSnippets[0])) {
let type = pathSnippets[0] === 'add-interface' ? 'interface' : pathSnippets[0],
id = pathSnippets[pathSnippets.length-1];
if (!pathSnippets.includes('edit')) {
if (pathSnippets.includes('add-interface') && !pathSnippets.includes('edit')) {
type = 'project';
}
const params = { type, id };
@ -50,12 +50,21 @@ export default class BreadcrumbNavigation extends Component {
path: '/project/' + data.project_id
}])
});
// '添加接口'页面根据project_id获取面包屑路径并在结尾追加"添加接口"
if (pathSnippets.includes('add-interface') && !pathSnippets.includes('edit')) {
this.setState({
breadcrumb: this.state.breadcrumb.concat([{
name: '添加接口',
path: '/add-interface/' + data.project_id
}])
});
}
}
if (data.interface_name) {
if (data.interface_name && pathSnippets.includes('edit')) {
this.setState({
breadcrumb: this.state.breadcrumb.concat([{
name: data.interface_name,
path: '/add-interface/' + data.interface_id
path: '/add-interface/edit/' + data.interface_id
}])
});
}