This commit is contained in:
qitmac000249 2017-08-17 20:08:30 +08:00
commit b7d87a4f0e
3 changed files with 20 additions and 13 deletions

View File

@ -1,7 +1,7 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { Row, Col, Tabs } from 'antd';
import { Route } from 'react-router-dom';
import { Route, Switch, Redirect } from 'react-router-dom';
import './interface.scss'
@ -75,7 +75,10 @@ class Interface extends Component {
</Col>
<Col span={18} >
<div className="right-content">
<Switch>
<Redirect exact from='/project/:id/interface/:action' to={'/project/' + this.props.match.params.id + '/interface/' + this.props.match.params.action + '/0'} />
<Route path="/project/:id/interface/:action/:actionId" component={InterfaceRoute} />
</Switch>
</div>
</Col>
</Row>

View File

@ -27,7 +27,8 @@ class Content extends Component {
match: PropTypes.object,
list: PropTypes.array,
curdata: PropTypes.object,
fetchInterfaceData: PropTypes.func
fetchInterfaceData: PropTypes.func,
history: PropTypes.object
}
constructor(props) {
super(props)
@ -50,6 +51,9 @@ class Content extends Component {
let _actionId;
_actionId = matchParams.actionId;
_actionId = parseInt(matchParams.actionId, 10);
if (_actionId == 0 && nextProps.list.length > 0) {
return this.props.history.replace('/project/' + matchParams.id + '/interface/api/' + nextProps.list[0]._id)
}
if (!nextProps.curdata) return;
if (this._actionId !== _actionId) {
this._actionId = _actionId;

View File

@ -62,11 +62,11 @@ class InterfaceMenu extends Component {
}
async handleRequest() {
let result = await this.props.fetchInterfaceList(this.props.projectId);
let params = this.props.match.params;
if(!params.actionId){
this.props.history.replace('/project/'+params.id + '/interface/api/' + result.payload.data[0]._id)
}
await this.props.fetchInterfaceList(this.props.projectId);
// if(!params.actionId){
// this.props.history.replace('/project/'+params.id + '/interface/api/' + result.payload.data[0]._id)
// }
}
componentWillMount() {