mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-21 05:19:42 +08:00
Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev
This commit is contained in:
commit
31adb69d0d
@ -261,13 +261,11 @@ export default class Run extends Component {
|
||||
},
|
||||
error: (err, header) => {
|
||||
try {
|
||||
if (isJsonData(header)) {
|
||||
err = json_parse(err);
|
||||
}
|
||||
} catch (e) {
|
||||
message.error(e.message)
|
||||
console.log(e)
|
||||
}
|
||||
message.error('请求异常')
|
||||
message.error(err || '请求异常')
|
||||
that.setState({ res: err || '请求失败', resHeader: header, validRes: [], test_status: 'error' })
|
||||
that.setState({ loading: false })
|
||||
that.bindAceEditor()
|
||||
|
@ -118,9 +118,9 @@ class InterfaceColContent extends Component {
|
||||
this.setState({
|
||||
rows: newRows
|
||||
})
|
||||
let status = 'error';
|
||||
let status = 'error', result;
|
||||
try {
|
||||
let result = await this.handleTest(curitem);
|
||||
result = await this.handleTest(curitem);
|
||||
if (result.code === 400) {
|
||||
status = 'error';
|
||||
} else if (result.code === 0) {
|
||||
@ -128,12 +128,12 @@ class InterfaceColContent extends Component {
|
||||
} else if (result.code === 1) {
|
||||
status = 'invalid'
|
||||
}
|
||||
this.reports[curitem._id] = result;
|
||||
this.records[curitem._id] = result.res_body;
|
||||
} catch (e) {
|
||||
status = 'error';
|
||||
console.error(e);
|
||||
result = e;
|
||||
}
|
||||
this.reports[curitem._id] = result;
|
||||
this.records[curitem._id] = result.res_body;
|
||||
|
||||
curitem = Object.assign({}, rows[i], { test_status: status });
|
||||
newRows = [].concat([], rows);
|
||||
@ -165,6 +165,12 @@ class InterfaceColContent extends Component {
|
||||
return new Promise((resolve, reject) => {
|
||||
let result = { code: 400, msg: '数据异常', validRes: [] };
|
||||
let that = this;
|
||||
|
||||
result.url = href;
|
||||
result.method = interfaceData.method;
|
||||
result.headers = that.getHeadersObj(interfaceData.req_headers);
|
||||
result.body = interfaceData.req_body_type === 'form' ? that.arrToObj(interfaceData.req_body_form) : interfaceData.req_body_other;
|
||||
|
||||
window.crossRequest({
|
||||
url: href,
|
||||
method: interfaceData.method,
|
||||
@ -172,10 +178,6 @@ class InterfaceColContent extends Component {
|
||||
data: interfaceData.req_body_type === 'form' ? that.arrToObj(interfaceData.req_body_form) : interfaceData.req_body_other,
|
||||
success: (res, header) => {
|
||||
res = json_parse(res);
|
||||
result.url = href;
|
||||
result.method = interfaceData.method;
|
||||
result.headers = that.getHeadersObj(interfaceData.req_headers);
|
||||
result.body = interfaceData.req_body_type === 'form' ? that.arrToObj(interfaceData.req_body_form) : interfaceData.req_body_other
|
||||
result.res_header = header;
|
||||
result.res_body = res;
|
||||
if (res && typeof res === 'object') {
|
||||
@ -198,10 +200,18 @@ class InterfaceColContent extends Component {
|
||||
reject(result)
|
||||
}
|
||||
},
|
||||
error: (res) => {
|
||||
error: (err, header) => {
|
||||
try {
|
||||
err = json_parse(err);
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
err = err || '请求异常';
|
||||
result.code = 400;
|
||||
result.msg = '请求异常'
|
||||
reject(res)
|
||||
result.res_header = header;
|
||||
result.res_body = err;
|
||||
reject(result)
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -320,7 +330,7 @@ class InterfaceColContent extends Component {
|
||||
label: '用例名称'
|
||||
},
|
||||
props: {
|
||||
style:{
|
||||
style: {
|
||||
width: '250px'
|
||||
}
|
||||
},
|
||||
@ -341,7 +351,7 @@ class InterfaceColContent extends Component {
|
||||
}]
|
||||
},
|
||||
props: {
|
||||
style:{
|
||||
style: {
|
||||
width: '100px'
|
||||
}
|
||||
},
|
||||
@ -357,7 +367,7 @@ class InterfaceColContent extends Component {
|
||||
label: '状态'
|
||||
},
|
||||
props: {
|
||||
style:{
|
||||
style: {
|
||||
width: '100px'
|
||||
}
|
||||
},
|
||||
@ -400,13 +410,13 @@ class InterfaceColContent extends Component {
|
||||
|
||||
},
|
||||
props: {
|
||||
style:{
|
||||
style: {
|
||||
width: '100px'
|
||||
}
|
||||
},
|
||||
cell: {
|
||||
formatters: [(text, { rowData }) => {
|
||||
if(!this.reports[rowData.id]){
|
||||
if (!this.reports[rowData.id]) {
|
||||
return null;
|
||||
}
|
||||
return <Button onClick={() => this.openReport(rowData.id)}>报告</Button>
|
||||
@ -439,7 +449,7 @@ class InterfaceColContent extends Component {
|
||||
<Table.Provider
|
||||
components={components}
|
||||
columns={resolvedColumns}
|
||||
style={{ width: '100%',borderCollapse: 'collapse' }}
|
||||
style={{ width: '100%', borderCollapse: 'collapse' }}
|
||||
>
|
||||
<Table.Header
|
||||
className="interface-col-table-header"
|
||||
|
Loading…
Reference in New Issue
Block a user