diff --git a/client/components/Postman/Postman.js b/client/components/Postman/Postman.js index 8c5e104e..cc1e98a4 100755 --- a/client/components/Postman/Postman.js +++ b/client/components/Postman/Postman.js @@ -1,7 +1,7 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import Mock from 'mockjs' -import { Button, Input, Select, Alert, Spin, Icon, Collapse, Tooltip, message, AutoComplete } from 'antd' +import { Button, Input, Select, Alert, Spin, Icon, Collapse, Tooltip, message, AutoComplete, Switch } from 'antd' import { autobind } from 'core-decorators'; import constants from '../../constants/variable.js' @@ -40,7 +40,7 @@ const mockDataSource = wordList.map(item => { }); -const { TextArea } = Input; +// const { TextArea } = Input; const InputGroup = Input.Group; const Option = Select.Option; const Panel = Collapse.Panel; @@ -71,7 +71,10 @@ export default class Run extends Component { loading: false, validRes: [], hasPlugin: true, - test_status: null + test_status: null, + resTest: false, + resStatusCode: null, + resStatusText: '' } constructor(props) { @@ -214,7 +217,12 @@ export default class Run extends Component { data: bodyType === 'form' ? this.arrToObj(bodyForm) : bodyOther, files: bodyType === 'form' ? this.getFiles(bodyForm) : {}, file: bodyType === 'file' ? 'single-file' : null, - success: (res, header) => { + success: (res, header, third) => { + console.log('suc',third); + this.setState({ + resStatusCode: third.res.status, + resStatusText: third.res.statusText + }) try { if (isJsonData(header)) { res = json_parse(res); @@ -259,7 +267,12 @@ export default class Run extends Component { console.error(e.message) } }, - error: (err, header) => { + error: (err, header, third) => { + console.log('err',third); + this.setState({ + resStatusCode: third.res.status, + resStatusText: third.res.statusText + }) try { err = json_parse(err); } catch (e) { @@ -496,6 +509,13 @@ export default class Run extends Component { console.log(index) } + @autobind + onTestSwitched(checked) { + this.setState({ + resTest: checked + }); + } + render() { const { method, domains, pathParam, pathname, query, headers, bodyForm, caseEnv, bodyType, resHeader, loading, validRes } = this.state; HTTP_METHOD[method] = HTTP_METHOD[method] || {} @@ -722,30 +742,59 @@ export default class Run extends Component {

返回结果

- -
- + {this.state.resStatusCode ? + +

= 200 && this.state.resStatusCode < 400 && !this.state.loading) ? 'success' : 'fail')}>{this.state.resStatusCode + ' ' + this.state.resStatusText}

+ +
+
+
+

Headers

+
+
+
+
+
+

1

+
+
+
+
+

Body

+
+
+
{this.state.res && this.state.res.toString()}
+
+
+
:

发送请求后在这里查看返回结果。

} + + {/* -
- -

返回 Body 验证结果:

-
- {validResView} -
-
- - {/**/} + {/* + */} + {/**/} -
+ {/*
-
-
+ */} + +

数据结构验证 + +

+
+ {(isResJson && this.state.resTest) ? validResView :

若开启此功能,则发送请求后在这里查看验证结果。

数据结构验证在接口编辑页面配置,YApi 将根据 Response body 验证请求返回的结果。

} +
) } diff --git a/client/containers/Project/Interface/InterfaceCol/InterfaceColContent.js b/client/containers/Project/Interface/InterfaceCol/InterfaceColContent.js index 3aaa1079..ec0d07f1 100755 --- a/client/containers/Project/Interface/InterfaceCol/InterfaceColContent.js +++ b/client/containers/Project/Interface/InterfaceCol/InterfaceColContent.js @@ -127,9 +127,9 @@ class InterfaceColContent extends Component { status = 'ok'; } else if (result.code === 1) { status = 'invalid' - } + } } catch (e) { - status = 'error'; + status = 'error'; result = e; } this.reports[curitem._id] = result; @@ -177,7 +177,7 @@ class InterfaceColContent extends Component { headers: that.getHeadersObj(interfaceData.req_headers), data: interfaceData.req_body_type === 'form' ? that.arrToObj(interfaceData.req_body_form) : interfaceData.req_body_other, success: (res, header) => { - res = json_parse(res); + res = json_parse(res); result.res_header = header; result.res_body = res; if (res && typeof res === 'object') { @@ -206,7 +206,7 @@ class InterfaceColContent extends Component { } catch (e) { console.log(e) } - + err = err || '请求异常'; result.code = 400; result.res_header = header; @@ -442,7 +442,7 @@ class InterfaceColContent extends Component { return (
-

测试集合  +

测试集合 

@@ -478,4 +478,4 @@ class InterfaceColContent extends Component { } } -export default InterfaceColContent \ No newline at end of file +export default InterfaceColContent diff --git a/client/containers/Project/Interface/InterfaceCol/InterfaceColMenu.scss b/client/containers/Project/Interface/InterfaceCol/InterfaceColMenu.scss index c8efc6ea..8df3e6b7 100755 --- a/client/containers/Project/Interface/InterfaceCol/InterfaceColMenu.scss +++ b/client/containers/Project/Interface/InterfaceCol/InterfaceColMenu.scss @@ -89,12 +89,11 @@ } .interface-col{ - padding: 16px; + padding: 24px; .interface-col-table-header{ background-color: rgb(238, 238, 238); height: 50px; line-height: 50px; - font-size:14px; text-align: left; } diff --git a/client/containers/Project/Interface/InterfaceList/Edit.scss b/client/containers/Project/Interface/InterfaceList/Edit.scss index 3e7a9095..8b61a0c5 100755 --- a/client/containers/Project/Interface/InterfaceList/Edit.scss +++ b/client/containers/Project/Interface/InterfaceList/Edit.scss @@ -1,3 +1,5 @@ +@import '../../../../styles/mixin.scss'; + .interface-edit{ padding: 24px; .interface-edit-item{ @@ -61,3 +63,71 @@ white-space: normal; word-break: break-all; } + +// 容器:左侧是header 右侧是body +.container-header-body { + display: flex; + padding-bottom: .36rem; + .header, .body { + flex: 1 0 300px; + .pretty-editor-header, .pretty-editor-body { + height: 100%; + } + .postman .pretty-editor-body { + min-height: 200px; + } + .ace_print-margin { + display: none; + } + } + .header { + max-width: 400px; + } + .container-title { + padding: .08rem 0; + } + .resizer { + flex: 0 0 21px; + position: relative; + &:after { + content: ''; + display: block; + width: 1px; + height: 100%; + background-color: $color-text-dark; + opacity: .8; + position: absolute; + left: 10px; + } + } + // res body 无返回json时显示text信息 + .res-body-text { + height: 100%; + border: 1px solid #d9d9d9; + border-radius: 4px; + padding: 8px; + } +} +.ant-spin-blur { + .res-code.success { + background-color: transparent; + } + .res-code.fail { + background-color: transparent; + } +} +.res-code { + padding: .08rem .28rem; + color: #fff; + margin-left: -.28rem; + margin-right: -.28rem; + transition: all .2s; + position: relative; + border-radius: 2px; +} +.res-code.success { + background-color: $color-antd-green; +} +.res-code.fail { + background-color: $color-antd-red; +} diff --git a/client/containers/Project/Interface/InterfaceList/View.js b/client/containers/Project/Interface/InterfaceList/View.js index d884d999..204e5477 100755 --- a/client/containers/Project/Interface/InterfaceList/View.js +++ b/client/containers/Project/Interface/InterfaceList/View.js @@ -277,7 +277,7 @@ class View extends Component { return

{item.example}

; } }, { - title: '备注', + title: '备注', dataIndex: 'desc', key: 'desc', render(_, item) { @@ -304,11 +304,11 @@ class View extends Component { 接口名称: {this.props.curData.title} - 创建人: + 创 建 人: {this.props.curData.username} - 状 态: + 状  态: {status[this.props.curData.status]} 更新时间: {formatTime(this.props.curData.up_time)} diff --git a/client/containers/Project/Interface/interface.scss b/client/containers/Project/Interface/interface.scss index c3db7e62..93dc5666 100755 --- a/client/containers/Project/Interface/interface.scss +++ b/client/containers/Project/Interface/interface.scss @@ -149,6 +149,17 @@ .right-content{ min-height: 5rem; background: #fff; + .caseContainer { + table { + border-radius: 4px; + // border-collapse: collapse; + } + .ant-table-small .ant-table-thead > tr > th { + text-align: left; + background-color: #f8f8f8; + } + tr:nth-child(even){background: #f8f8f8;} + } .interface-content{ .ant-tabs-nav{ width:100%; @@ -195,11 +206,17 @@ } th { text-align: left; + font-weight: normal; + background-color: #f8f8f8; + text-indent: .4em; + } + tr { + text-indent: .4em; } th, td { border: 1px solid #e9e9e9; - padding: 8px; } - tr:nth-child(odd){background: rgba(236, 238, 241, 0.67);} + tr:nth-child(odd){background: #f8f8f8;} + tr:nth-child(even){background: #fff;} } } diff --git a/client/containers/Project/Setting/ProjectMember/ProjectMember.js b/client/containers/Project/Setting/ProjectMember/ProjectMember.js index 573119ba..b3f30c71 100755 --- a/client/containers/Project/Setting/ProjectMember/ProjectMember.js +++ b/client/containers/Project/Setting/ProjectMember/ProjectMember.js @@ -234,7 +234,7 @@ class ProjectMember extends Component { }} className="setting-project-member"/> - + {this.state.groupMemberList.length ? this.state.groupMemberList.map((item, index) => { return (