fix(接口定义): 修复执行缺陷

This commit is contained in:
fit2-zhao 2020-12-11 16:50:49 +08:00
parent f6d4f6257a
commit b6401b776f
3 changed files with 12 additions and 4 deletions

View File

@ -154,7 +154,10 @@
} }
}, },
handleTabAdd(e) { handleTabAdd(e) {
let api = {status: "Underway", method: "GET", userId: getCurrentUser().id, url: "", protocol: this.currentProtocol}; let api = {
status: "Underway", method: "GET", userId: getCurrentUser().id,
url: "", protocol: this.currentProtocol, environmentId: ""
};
this.handleTabsEdit(this.$t('api_test.definition.request.title'), e, api); this.handleTabsEdit(this.$t('api_test.definition.request.title'), e, api);
}, },
handleTabClose() { handleTabClose() {

View File

@ -64,7 +64,11 @@
break; break;
} }
if (this.currentApi.response != null && this.currentApi.response != 'null' && this.currentApi.response != undefined) { if (this.currentApi.response != null && this.currentApi.response != 'null' && this.currentApi.response != undefined) {
this.response = new ResponseFactory(JSON.parse(this.currentApi.response)); if (Object.prototype.toString.call(this.currentApi.response).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') {
this.response = this.currentApi.response;
} else {
this.response = new ResponseFactory(JSON.parse(this.currentApi.response));
}
} else { } else {
this.response = {headers: [], body: new Body(), statusCode: [], type: "HTTP"}; this.response = {headers: [], body: new Body(), statusCode: [], type: "HTTP"};
} }

View File

@ -236,7 +236,7 @@
let hasEnvironment = false; let hasEnvironment = false;
for (let i in this.environments) { for (let i in this.environments) {
if (this.environments[i].id === this.api.environmentId) { if (this.environments[i].id === this.api.environmentId) {
this.api.environment = this.environments[i]; this.api.environmentId = this.environments[i];
hasEnvironment = true; hasEnvironment = true;
break; break;
} }
@ -261,7 +261,8 @@
environmentChange(value) { environmentChange(value) {
for (let i in this.environments) { for (let i in this.environments) {
if (this.environments[i].id === value) { if (this.environments[i].id === value) {
this.api.request.useEnvironment = this.environments[i].id; this.api.environmentId = value;
this.api.request.useEnvironment = value;
break; break;
} }
} }