fix: 修改测试返回数据mode问题

This commit is contained in:
gaoxiaolin.gao 2018-07-20 16:41:30 +08:00
parent b38ea0cc31
commit 8f09803b8b
3 changed files with 8 additions and 5 deletions

View File

@ -44,6 +44,7 @@ class AceEditor extends React.PureComponent {
});
let mode = this.props.mode || 'javascript';
this.editor.editor.getSession().setMode(getMode(mode));
if (typeof this.props.callback === 'function') {
this.props.callback(this.editor.editor);

View File

@ -861,7 +861,7 @@ export default class Run extends Component {
readOnly={true}
className="pretty-editor-header"
data={this.state.test_res_header}
mode="json"
mode="json"
/>
</div>
<div className="resizer">
@ -878,6 +878,7 @@ export default class Run extends Component {
className="pretty-editor-body"
data={this.state.test_res_body}
mode={handleContentType(this.state.test_res_header)}
// mode="html"
/>
</div>
</div>

View File

@ -12,8 +12,10 @@ const isNode = typeof global == 'object' && global.global === global;
const ContentTypeMap = {
'application/json': 'json',
'application/xml': 'xml',
other: 'text',
'application/html': 'html'
'text/xml': 'xml',
'application/html': 'html',
'text/html': 'html',
other: 'text'
};
async function httpRequestByNode(options) {
@ -344,7 +346,6 @@ function handleParams(interfaceData, handleValue, requestParams) {
path = path.replace(`{${item.name}}`, val || `{${item.name}}`);
});
const urlObj = URL.parse(joinPath(currDomain.domain, path), true);
const url = URL.format({
protocol: urlObj.protocol || 'http',
@ -404,7 +405,7 @@ function handleParams(interfaceData, handleValue, requestParams) {
if (requestParams) {
requestParams = Object.assign(requestParams, reqBody);
}
requestBody = handleJson(reqBody, (val)=>handleValue(val, currDomain.global));
requestBody = handleJson(reqBody, val => handleValue(val, currDomain.global));
}
} else {
requestBody = interfaceRunData.req_body_other;