From 604ebcc8da1427761b6ebcde4eccbbcdad732e3c Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Thu, 2 Dec 2021 19:00:41 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E8=B0=83=E8=AF=95=E6=97=B6=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1008520 --user=lyh 【github#6612】jmeter调试好的场景,有环境变量,导入MS还提示要选择场景变量。并且还识别不到HTTP请求头中的端口 https://www.tapd.cn/55049933/s/1077469 --- .../api/service/ApiAutomationService.java | 2 +- .../api/automation/scenario/EnvPopover.vue | 26 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index f093a8a167..c03dcb39f3 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -933,7 +933,7 @@ public class ApiAutomationService { // 校验是否是全路径 MsHTTPSamplerProxy httpSamplerProxy = (MsHTTPSamplerProxy) tr; if (httpSamplerProxy.isEnable()) { - if (StringUtils.isBlank(httpSamplerProxy.getUrl()) || !ElementUtil.isURL(httpSamplerProxy.getUrl())) { + if (StringUtils.isBlank(httpSamplerProxy.getUrl()) || (httpSamplerProxy.getIsRefEnvironment() != null && httpSamplerProxy.getIsRefEnvironment())) { env.setFullUrl(false); env.getProjectIds().add(httpSamplerProxy.getProjectId()); } diff --git a/frontend/src/business/components/api/automation/scenario/EnvPopover.vue b/frontend/src/business/components/api/automation/scenario/EnvPopover.vue index aaf7f2979b..0114ced0be 100644 --- a/frontend/src/business/components/api/automation/scenario/EnvPopover.vue +++ b/frontend/src/business/components/api/automation/scenario/EnvPopover.vue @@ -135,15 +135,23 @@ export default { }, checkEnv(data) { return new Promise((resolve => { - if (this.environmentType === ENV_TYPE.JSON) { - let res = this.$refs.envSelect.checkEnv(data); - resolve(res); - } else if (this.environmentType === ENV_TYPE.GROUP) { - let res = !this.hasOptionGroup ? this.$refs.envGroup.checkEnv() : - this.$refs.envOptionGroup.checkEnv(); - res.then(r => { - resolve(r); - }) + if (data) { + // 所有请求全路径不检查环境 + resolve(true); + } else { + if (!this.environmentType) { + this.$warning("请选择环境!"); + resolve(false); + } else if (this.environmentType === ENV_TYPE.JSON) { + let res = this.$refs.envSelect.checkEnv(data); + resolve(res); + } else if (this.environmentType === ENV_TYPE.GROUP) { + let res = !this.hasOptionGroup ? this.$refs.envGroup.checkEnv() : + this.$refs.envOptionGroup.checkEnv(); + res.then(r => { + resolve(r); + }) + } } })) },