From 324cc0fd5f527c57359b5850a7d760ec15101040 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 26 Jan 2021 14:07:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8D=E6=97=A7=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=E9=80=89=E6=8B=A9=E6=A8=A1=E5=9D=97=E6=A0=B9?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/api/definition/ApiDefinition.vue | 10 +++++++--- frontend/src/business/components/api/test/Upgrade.vue | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/frontend/src/business/components/api/definition/ApiDefinition.vue b/frontend/src/business/components/api/definition/ApiDefinition.vue index 9b47c97278..faedc0c205 100644 --- a/frontend/src/business/components/api/definition/ApiDefinition.vue +++ b/frontend/src/business/components/api/definition/ApiDefinition.vue @@ -220,14 +220,14 @@ if (tab.name === 'add') { this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug"); } - if(this.$refs.apiConfig) { + if (this.$refs.apiConfig) { this.$refs.apiConfig.forEach(item => { console.log(item); item.removeListener(); }); // 删除所有tab的 ctrl + s 监听 let tabs = this.apiTabs; let index = tabs.findIndex(item => item.name === tab.name); // 找到当前选中tab的index - if(index != -1) { + if (index != -1) { this.$refs.apiConfig[index - 1].addListener(); // 为选中tab添加 ctrl + s 监听(index-1的原因是要除去第一个固有tab) } } @@ -336,7 +336,11 @@ } else { let condition = {}; let url = "/api/definition/list/all"; - condition.filters = ["Prepare", "Underway", "Completed"]; + condition.filters = new Map( + [ + ["status", ["Prepare", "Underway", "Completed"]], + ] + ); condition.projectId = getCurrentProjectID(); this.$post(url, condition, response => { obj.data = response.data; diff --git a/frontend/src/business/components/api/test/Upgrade.vue b/frontend/src/business/components/api/test/Upgrade.vue index ecc125082c..354b7c785d 100644 --- a/frontend/src/business/components/api/test/Upgrade.vue +++ b/frontend/src/business/components/api/test/Upgrade.vue @@ -11,6 +11,7 @@ Date: Tue, 26 Jan 2021 14:15:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8D=E5=BF=AB=E6=8D=B7=E8=B0=83?= =?UTF-8?q?=E8=AF=95=EF=BC=8Curl=E5=8F=82=E6=95=B0=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/debug/DebugHttpPage.vue | 33 +++++++++++++++++-- .../business/components/api/test/Upgrade.vue | 1 - 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/frontend/src/business/components/api/definition/components/debug/DebugHttpPage.vue b/frontend/src/business/components/api/definition/components/debug/DebugHttpPage.vue index 7bef849ff2..39d0243fb7 100644 --- a/frontend/src/business/components/api/definition/components/debug/DebugHttpPage.vue +++ b/frontend/src/business/components/api/definition/components/debug/DebugHttpPage.vue @@ -7,7 +7,7 @@ + class="ms-http-input" size="small" :disabled="testCase!=undefined" @blur="urlChange"> @@ -55,6 +55,7 @@ import {REQ_METHOD} from "../../model/JsonData"; import MsRequestResultTail from "../response/RequestResultTail"; import MsJmxStep from "../step/JmxStep"; + import {KeyValue} from "../../model/ApiTestModel"; export default { name: "ApiConfig", @@ -167,7 +168,35 @@ return false; } }) - } + }, + urlChange() { + if (!this.debugForm.url || this.debugForm.url.indexOf('?') === -1) return; + let url = this.getURL(this.addProtocol(this.debugForm.url)); + if (url) { + this.debugForm.url = decodeURIComponent(this.debugForm.url.substr(0, this.debugForm.url.indexOf("?"))); + } + }, + addProtocol(url) { + if (url) { + if (!url.toLowerCase().startsWith("https") && !url.toLowerCase().startsWith("http")) { + return "https://" + url; + } + } + return url; + }, + getURL(urlStr) { + try { + let url = new URL(urlStr); + url.searchParams.forEach((value, key) => { + if (key && value) { + this.request.arguments.splice(0, 0, new KeyValue({name: key, required: false, value: value})); + } + }); + return url; + } catch (e) { + this.$error(this.$t('api_test.request.url_invalid'), 2000); + } + }, } } diff --git a/frontend/src/business/components/api/test/Upgrade.vue b/frontend/src/business/components/api/test/Upgrade.vue index 354b7c785d..51149c0843 100644 --- a/frontend/src/business/components/api/test/Upgrade.vue +++ b/frontend/src/business/components/api/test/Upgrade.vue @@ -98,7 +98,6 @@ this.$warning("请选择一个模块"); return; } - console.log(this.currentModule) if (this.currentModule.id === "root") { this.$warning("不能选默认模块,请重新选择一个模块"); return;