yapi/client/containers/Project/Project.js

64 lines
1.6 KiB
JavaScript
Raw Normal View History

2017-08-10 16:00:52 +08:00
import React, { Component } from 'react'
2017-08-11 17:24:50 +08:00
import { connect } from 'react-redux';
2017-08-10 16:00:52 +08:00
import PropTypes from 'prop-types'
2017-08-10 20:56:08 +08:00
import { Route, Switch, Redirect } from 'react-router-dom';
import { Subnav } from '../../components/index'
2017-08-11 17:24:50 +08:00
import { getProject } from '../../reducer/modules/project';
2017-08-11 17:29:37 +08:00
import Interface from './Interface/Interface.js'
2017-08-14 15:17:05 +08:00
import Activity from './Activity/Activity.js'
2017-08-11 16:30:52 +08:00
import { Setting } from './Setting/Setting.js'
2017-08-10 16:00:52 +08:00
2017-08-11 17:24:50 +08:00
@connect(
state => {
return {
curProject: state.project.currProject
2017-08-11 17:24:50 +08:00
}
},
{
getProject
2017-08-10 16:00:52 +08:00
}
2017-08-11 17:24:50 +08:00
)
export default class Project extends Component {
2017-08-10 16:00:52 +08:00
2017-08-11 17:24:50 +08:00
static propTypes = {
match: PropTypes.object,
curProject: PropTypes.object,
getProject: PropTypes.func
2017-08-10 16:00:52 +08:00
}
constructor(props) {
super(props)
}
componentWillMount() {
2017-08-11 18:57:58 +08:00
this.props.getProject(this.props.match.params.id)
2017-08-10 16:00:52 +08:00
}
render () {
2017-08-11 10:44:33 +08:00
const { match } = this.props;
2017-08-10 16:00:52 +08:00
return (
<div>
2017-08-10 20:56:08 +08:00
<Subnav
2017-08-11 21:10:54 +08:00
default={'动态'}
2017-08-10 20:56:08 +08:00
data={[{
name: '接口',
2017-08-16 18:04:16 +08:00
path: `/project/${match.params.id}/interface/api`
2017-08-10 20:56:08 +08:00
}, {
name: '设置',
2017-08-11 10:44:33 +08:00
path: `/project/${match.params.id}/setting`
2017-08-10 20:56:08 +08:00
}, {
name: '动态',
2017-08-11 10:44:33 +08:00
path: `/project/${match.params.id}/activity`
2017-08-10 20:56:08 +08:00
}]}/>
2017-08-10 20:08:23 +08:00
<Switch>
2017-08-11 21:10:54 +08:00
<Redirect exact from="/project/:id" to={`/project/${match.params.id}/activity`}/>
2017-08-11 16:30:52 +08:00
<Route path="/project/:id/activity" component={Activity} />
2017-08-16 18:04:16 +08:00
<Route path="/project/:id/interface/:action" component={Interface} />
2017-08-11 16:30:52 +08:00
<Route path="/project/:id/setting" component={Setting} />
2017-08-10 20:08:23 +08:00
</Switch>
2017-08-10 16:00:52 +08:00
</div>
)
}
}