From f7fd033055e64a27bfa568f264c8fa85ff0a3681 Mon Sep 17 00:00:00 2001 From: zwjamnsss Date: Wed, 26 Jul 2017 17:53:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AF=B7=E6=B1=82=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InterfaceTest/InterfaceTest.js | 55 ++++++++++++------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/client/containers/AddInterface/InterfaceTest/InterfaceTest.js b/client/containers/AddInterface/InterfaceTest/InterfaceTest.js index 51f2f830..a9c3b59c 100644 --- a/client/containers/AddInterface/InterfaceTest/InterfaceTest.js +++ b/client/containers/AddInterface/InterfaceTest/InterfaceTest.js @@ -1,7 +1,7 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' -import { Button, Input } from 'antd' +import { Button, Input, Select } from 'antd' import { autobind } from 'core-decorators'; import crossRequest from 'cross-request'; import { withRouter } from 'react-router'; @@ -13,6 +13,8 @@ import { import './InterfaceTest.scss' const { TextArea } = Input; +const InputGroup = Input.Group; +const Option = Select.Option; @connect( state => ({ @@ -40,7 +42,7 @@ export default class InterfaceTest extends Component { } state = { - res: {}, + res: '', header: {} } @@ -57,9 +59,8 @@ export default class InterfaceTest extends Component { const { method, url, seqGroup, interfaceProject } = this.props; const { prd_host, basepath, protocol } = interfaceProject; const reqParams = JSON.parse(this.props.reqParams); - const headers = {} - let query = {}; + const query = {}; if (method === 'GET') { Object.keys(reqParams).forEach(key => { const value = typeof reqParams[key] === 'object' ? JSON.stringify(reqParams) : reqParams.toString(); @@ -67,8 +68,11 @@ export default class InterfaceTest extends Component { }) } + const headers = {} seqGroup.forEach((headerItem) => { - headers[headerItem.name] = headerItem.value; + if (headerItem.name) { + headers[headerItem.name] = headerItem.value; + } }) const href = URL.format({ @@ -95,10 +99,16 @@ export default class InterfaceTest extends Component { render () { const { method, url, seqGroup, interfaceName, interfaceProject } = this.props; - const { prd_host, basepath, protocol } = interfaceProject; + const { prd_host, basepath, protocol, env } = interfaceProject; const reqParams = JSON.parse(this.props.reqParams); - let query = {}; + const pathname = (basepath + url).replace(/\/+/g, '/'); + const domains = [{name: 'prd', domain: protocol + '://' + prd_host}]; + env.forEach(item => { + domains.push({name: item.name, domain: item.domain}); + }) + + const query = {}; if (method === 'GET') { Object.keys(reqParams).forEach(key => { const value = typeof reqParams[key] === 'object' ? JSON.stringify(reqParams[key]) : reqParams[key].toString(); @@ -106,10 +116,8 @@ export default class InterfaceTest extends Component { }) } - const href = URL.format({ - protocol: protocol || 'http', - host: prd_host, - pathname: (basepath + url).replace(/\/+/g, '/'), + + const search = URL.format({ query }); @@ -118,22 +126,27 @@ export default class InterfaceTest extends Component {
{interfaceName}
-
- METHOD: -
-
- URL: - +
+ + + + + +
HEADERS: { seqGroup.map((headerItem, index) => { return ( -
+ headerItem.name ? (
{' = '} -
+
) : '' ) }) } @@ -155,7 +168,9 @@ export default class InterfaceTest extends Component {
返回结果: - +
+ +
)