From b6401b776f2cd2bd253d88f304ae871ce0ce34db Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Fri, 11 Dec 2020 16:50:49 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=A7=E8=A1=8C=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/components/api/definition/ApiDefinition.vue | 5 ++++- .../components/api/definition/components/ApiConfig.vue | 6 +++++- .../api/definition/components/runtest/RunTestHTTPPage.vue | 5 +++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend/src/business/components/api/definition/ApiDefinition.vue b/frontend/src/business/components/api/definition/ApiDefinition.vue index 1c07087dfd..a3d9095a71 100644 --- a/frontend/src/business/components/api/definition/ApiDefinition.vue +++ b/frontend/src/business/components/api/definition/ApiDefinition.vue @@ -154,7 +154,10 @@ } }, 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); }, handleTabClose() { diff --git a/frontend/src/business/components/api/definition/components/ApiConfig.vue b/frontend/src/business/components/api/definition/components/ApiConfig.vue index e9e1ae765b..1df8d46921 100644 --- a/frontend/src/business/components/api/definition/components/ApiConfig.vue +++ b/frontend/src/business/components/api/definition/components/ApiConfig.vue @@ -64,7 +64,11 @@ break; } 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 { this.response = {headers: [], body: new Body(), statusCode: [], type: "HTTP"}; } diff --git a/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue b/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue index c65a36cc60..1b2ba625bb 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue @@ -236,7 +236,7 @@ let hasEnvironment = false; for (let i in this.environments) { if (this.environments[i].id === this.api.environmentId) { - this.api.environment = this.environments[i]; + this.api.environmentId = this.environments[i]; hasEnvironment = true; break; } @@ -261,7 +261,8 @@ environmentChange(value) { for (let i in this.environments) { if (this.environments[i].id === value) { - this.api.request.useEnvironment = this.environments[i].id; + this.api.environmentId = value; + this.api.request.useEnvironment = value; break; } }