2017-08-11 17:24:50 +08:00
|
|
|
import React, { Component } from 'react'
|
2017-08-11 18:57:58 +08:00
|
|
|
import PropTypes from 'prop-types'
|
2017-08-11 17:24:50 +08:00
|
|
|
import { Row, Col, Tabs } from 'antd';
|
2017-08-17 18:00:02 +08:00
|
|
|
import { Route, Switch, Redirect } from 'react-router-dom';
|
2017-08-16 18:04:16 +08:00
|
|
|
|
2017-08-11 17:24:50 +08:00
|
|
|
import './interface.scss'
|
|
|
|
|
|
|
|
import InterfaceMenu from './InterfaceList/InterfaceMenu.js'
|
|
|
|
import InterfaceContent from './InterfaceList/InterfaceContent.js'
|
|
|
|
|
|
|
|
import InterfaceColMenu from './InterfaceCol/InterfaceColMenu.js'
|
|
|
|
import InterfaceColContent from './InterfaceCol/InterfaceColContent.js'
|
2017-08-17 16:10:34 +08:00
|
|
|
import InterfaceCaseContent from './InterfaceCol/InterfaceCaseContent.js'
|
2017-08-11 17:24:50 +08:00
|
|
|
|
2017-08-17 11:24:46 +08:00
|
|
|
const InterfaceRoute = (props) => {
|
|
|
|
let C;
|
|
|
|
if (props.match.params.action === 'api') {
|
|
|
|
C = InterfaceContent;
|
|
|
|
} else if (props.match.params.action === 'col') {
|
|
|
|
C = InterfaceColContent;
|
2017-08-17 16:10:34 +08:00
|
|
|
} else if (props.match.params.action === 'case') {
|
|
|
|
C = InterfaceCaseContent;
|
2017-08-16 18:04:16 +08:00
|
|
|
}
|
2017-08-17 11:24:46 +08:00
|
|
|
return <C />
|
|
|
|
}
|
|
|
|
|
|
|
|
InterfaceRoute.propTypes = {
|
|
|
|
match: PropTypes.object
|
2017-08-16 18:04:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-08-11 17:24:50 +08:00
|
|
|
class Interface extends Component {
|
2017-08-11 18:57:58 +08:00
|
|
|
static propTypes = {
|
2017-08-17 16:10:34 +08:00
|
|
|
match: PropTypes.object,
|
|
|
|
history: PropTypes.object
|
2017-08-11 18:57:58 +08:00
|
|
|
}
|
2017-08-11 17:24:50 +08:00
|
|
|
|
|
|
|
constructor(props) {
|
2017-08-16 18:04:16 +08:00
|
|
|
super(props)
|
2017-08-11 17:24:50 +08:00
|
|
|
this.state = {
|
2017-08-16 18:04:16 +08:00
|
|
|
curkey: this.props.match.params.action
|
2017-08-11 17:24:50 +08:00
|
|
|
}
|
2017-08-17 16:10:34 +08:00
|
|
|
console.log(this.props)
|
2017-08-11 17:24:50 +08:00
|
|
|
}
|
|
|
|
|
2017-08-17 16:10:34 +08:00
|
|
|
onChange = (action) => {
|
|
|
|
let params = this.props.match.params;
|
2017-08-17 20:24:07 +08:00
|
|
|
|
2017-08-17 16:10:34 +08:00
|
|
|
this.props.history.push('/project/'+params.id + '/interface/' + action)
|
2017-08-11 17:24:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2017-08-17 20:24:07 +08:00
|
|
|
const { action, id } = this.props.match.params;
|
2017-08-11 17:24:50 +08:00
|
|
|
return <div className="web-content g-row" style={{ marginBottom: "15px" }}>
|
|
|
|
<Row gutter={16} >
|
|
|
|
<Col span={6}>
|
|
|
|
<div className="left-menu">
|
2017-08-17 16:10:34 +08:00
|
|
|
<Tabs type="card" activeKey={action} onChange={this.onChange}>
|
2017-08-16 18:04:16 +08:00
|
|
|
<Tabs.TabPane tab="接口列表" key="api">
|
2017-08-11 18:57:58 +08:00
|
|
|
<InterfaceMenu projectId={this.props.match.params.id} />
|
2017-08-11 17:24:50 +08:00
|
|
|
</Tabs.TabPane>
|
2017-08-16 10:56:42 +08:00
|
|
|
<Tabs.TabPane tab="接口集合" key="col" >
|
2017-08-11 17:24:50 +08:00
|
|
|
<InterfaceColMenu />
|
|
|
|
</Tabs.TabPane>
|
|
|
|
</Tabs>
|
|
|
|
</div>
|
|
|
|
|
2017-08-16 18:04:16 +08:00
|
|
|
|
2017-08-11 17:24:50 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={18} >
|
|
|
|
<div className="right-content">
|
2017-08-17 18:00:02 +08:00
|
|
|
<Switch>
|
2017-08-17 20:25:44 +08:00
|
|
|
<Redirect exact from='/project/:id/interface/:action' to={'/project/' + id + '/interface/' + action + '/0'} />
|
2017-08-17 18:00:02 +08:00
|
|
|
<Route path="/project/:id/interface/:action/:actionId" component={InterfaceRoute} />
|
|
|
|
</Switch>
|
2017-08-11 17:24:50 +08:00
|
|
|
</div>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-16 18:04:16 +08:00
|
|
|
|
|
|
|
|
2017-08-17 16:10:34 +08:00
|
|
|
export default Interface
|