feat: run

This commit is contained in:
zwjamnsss 2017-08-14 21:22:18 +08:00
parent 57f2b872c3
commit 129708f264
2 changed files with 30 additions and 29 deletions

View File

@ -5,7 +5,7 @@ import { Button, Input, Select, Card, Alert, Spin, Icon, message } from 'antd'
import { autobind } from 'core-decorators';
import crossRequest from 'cross-request';
import { withRouter } from 'react-router';
import axios from 'axios';
// import axios from 'axios';
import URL from 'url';
// import {
@ -19,25 +19,27 @@ const Option = Select.Option;
@connect(
state => ({
reqParams: state.addInterface.reqParams,
method: state.addInterface.method,
url: state.addInterface.url,
seqGroup: state.addInterface.seqGroup,
interfaceName: state.addInterface.interfaceName,
interfaceProject: state.addInterface.project
currInterface: state.inter.curdata,
currProject: state.project.currProject
// reqParams: state.addInterface.reqParams,
// method: state.addInterface.method,
// url: state.addInterface.url,
// seqGroup: state.addInterface.seqGroup,
// interfaceName: state.addInterface.interfaceName,
})
)
@withRouter
export default class InterfaceTest extends Component {
static propTypes = {
reqParams: PropTypes.string,
method: PropTypes.string,
url: PropTypes.string,
interfaceName: PropTypes.string,
seqGroup: PropTypes.array,
match: PropTypes.object,
interfaceProject: PropTypes.object
currProject: PropTypes.object,
currInterface: PropTypes.object,
reqParams: PropTypes.string,
// method: PropTypes.string,
// url: PropTypes.string,
interfaceName: PropTypes.string
// seqGroup: PropTypes.array,
}
state = {
@ -68,8 +70,11 @@ export default class InterfaceTest extends Component {
@autobind
getInterfaceState(nextProps) {
const props = nextProps || this.props;
const { method, url, seqGroup, interfaceProject } = props;
const { prd_host, basepath, protocol, env } = interfaceProject;
const { currInterface, currProject } = props;
console.log('currInterface', currInterface)
console.log('currProject', currProject)
const { method, path: url, req_headers } = currInterface;
const { prd_host, basepath, protocol, env } = currProject;
const pathname = (basepath + url).replace(/\/+/g, '/');
const domains = {prd: protocol + '://' + prd_host};
@ -104,7 +109,7 @@ export default class InterfaceTest extends Component {
const headers = []
let contentTypeIndex = -1;
seqGroup.forEach((headerItem, index) => {
req_headers.forEach((headerItem, index) => {
if (headerItem.name) {
// TODO 'Content-Type' 排除大小写不同格式影响
if (headerItem.name === 'Content-Type'){
@ -350,10 +355,6 @@ export default class InterfaceTest extends Component {
const hasPlugin = this.hasCrossRequestPlugin();
const search = decodeURIComponent(URL.format({query: this.getQueryObj(query)}));
console.log(axios)
window.axios = axios
return (
<div className="interface-test">
<div style={{padding: '0 20%'}}>

View File

@ -8,7 +8,7 @@ const PROJECT_DEL = 'yapi/project/PROJECT_DEL';
const CHANGE_UPDATE_MODAL = 'yapi/project/CHANGE_UPDATE_MODAL';
const CHANGE_TABLE_LOADING = 'yapi/project/CHANGE_TABLE_LOADING';
const PROJECT_UPDATE = 'yapi/project/PROJECT_UPDATE';
const GET_CUR_PROJECT = 'yapi/project/GET_CUR_PROJECT'
const GET_CURR_PROJECT = 'yapi/project/GET_CURR_PROJECT'
// Reducer
const initialState = {
@ -19,15 +19,15 @@ const initialState = {
tableLoading: true,
total: 0,
currPage: 1,
curProject: {}
currProject: {}
};
export default (state = initialState, action) => {
switch (action.type) {
case GET_CUR_PROJECT: {
case GET_CURR_PROJECT: {
return {
...state,
curProject: action.payload.data
currProject: action.payload.data
}
}
case CHANGE_UPDATE_MODAL: {
@ -136,7 +136,7 @@ export function getProject(id){
return async (dispatch) => {
let result = await axios.get('/api/project/get?id=' + id);
dispatch({
type: GET_CUR_PROJECT,
type: GET_CURR_PROJECT,
payload: result.data
})
}