From 47f0333392e6de7b03f5bb6c26c6dbdae3fd0da5 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Wed, 7 Apr 2021 11:07:34 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BB=A3=E7=A0=81=E8=A7=84?= =?UTF-8?q?=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scenario/maximize/ScenarioHeader.vue | 4 +- .../components/track/common/EnvPopover.vue | 2 +- .../components/track/common/EnvSelect.vue | 123 +----------------- 3 files changed, 5 insertions(+), 124 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/maximize/ScenarioHeader.vue b/frontend/src/business/components/api/automation/scenario/maximize/ScenarioHeader.vue index b17bcabaa3..61ba4344a6 100644 --- a/frontend/src/business/components/api/automation/scenario/maximize/ScenarioHeader.vue +++ b/frontend/src/business/components/api/automation/scenario/maximize/ScenarioHeader.vue @@ -119,8 +119,8 @@ return new Promise((resolve) => { this.$post("/api/automation/getApiScenarioEnv", {definition: definition}, res => { if (res.data) { - this.$emit("update:projectIds", new Set(res.data.projectIds)) - this.$emit("update:isFullUrl", res.data.fullUrl) + this.$emit("update:projectIds", new Set(res.data.projectIds)); + this.$emit("update:isFullUrl", res.data.fullUrl); } resolve(); }) diff --git a/frontend/src/business/components/track/common/EnvPopover.vue b/frontend/src/business/components/track/common/EnvPopover.vue index ddc21d9156..53e730de9b 100644 --- a/frontend/src/business/components/track/common/EnvPopover.vue +++ b/frontend/src/business/components/track/common/EnvPopover.vue @@ -35,7 +35,7 @@ export default { data() { return { visible: false - } + }; }, methods: { showPopover() { diff --git a/frontend/src/business/components/track/common/EnvSelect.vue b/frontend/src/business/components/track/common/EnvSelect.vue index f88f2b53a7..2e57de6c51 100644 --- a/frontend/src/business/components/track/common/EnvSelect.vue +++ b/frontend/src/business/components/track/common/EnvSelect.vue @@ -48,7 +48,7 @@ export default { environments: [], dialogVisible: false, isFullUrl: true, - } + }; }, methods: { init() { @@ -68,7 +68,7 @@ export default { let envId = this.envMap.get(id); // 选中环境是否存在 temp.selectEnv = envs.filter(e => e.id === envId).length === 0 ? null : envId; - }) + }); } }) }, @@ -106,122 +106,6 @@ export default { this.$emit('setProjectEnvMap', map); this.$emit('close'); }, - getApiInfo(request) { - if (request.id && request.referenced === 'REF') { - let requestResult = request.requestResult; - let url = request.refType && request.refType === 'CASE' ? "/api/testcase/get/" : "/api/definition/get/"; - let enable = request.enable; - this.$get(url + request.id, response => { - if (response.data) { - Object.assign(request, JSON.parse(response.data.request)); - request.name = response.data.name; - request.enable = enable; - if (response.data.path && response.data.path != null) { - request.path = response.data.path; - request.url = response.data.url; - this.setUrl(request.path); - } - if (response.data.method && response.data.method != null) { - request.method = response.data.method; - } - request.requestResult = requestResult; - request.id = response.data.id; - request.disabled = true; - request.root = true; - if (!request.projectId) { - request.projectId = response.data.projectId; - } - this.reload(); - this.sort(); - } else { - request.referenced = "Deleted"; - } - }) - } - }, - getScenario(scenario) { - this.result = this.$get("/api/automation/getApiScenario/" + scenario.id, response => { - if (response.data) { - scenario.loaded = true; - let obj = {}; - if (response.data.scenarioDefinition) { - obj = JSON.parse(response.data.scenarioDefinition); - scenario.hashTree = obj.hashTree; - } - //scenario.disabled = true; - scenario.name = response.data.name; - if (!scenario.projectId) { - scenario.projectId = response.data.projectId; - } - scenario.headers = obj.headers; - scenario.variables = obj.variables; - scenario.environmentMap = obj.environmentMap; - this.$emit('refReload'); - } else { - scenario.referenced = "Deleted"; - } - }) - }, - recursiveSorting(arr) { - for (let i in arr) { - if (arr[i].referenced === 'REF') { - // 分场景和接口 - if (arr[i].type === "HTTPSamplerProxy") { - // 获取源头内容 - this.getApiInfo(arr[i]); - // 校验是否是全路径 - if (!arr[i].url || (!arr[i].url.startsWith("http://") && !arr[i].url.startsWith("https://"))) { - this.isFullUrl = false; - } - } else if (arr[i].type === "scenario") { - this.getScenario(arr[i]); - } - - } else { - if (arr[i].type === "HTTPSamplerProxy") { - // 校验是否是全路径 - if (arr[i].enable) { - if (!arr[i].url || (!arr[i].url.startsWith("http://") && !arr[i].url.startsWith("https://"))) { - this.isFullUrl = false; - } - } - } - } - if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) { - this.recursiveSorting(arr[i].hashTree); - } - } - }, - checkFullUrl(scenarioDefinition) { - for (let i in scenarioDefinition) { - // 设置项目ID - let request = scenarioDefinition[i]; - if (request.referenced === 'REF') { - if (request.type === "HTTPSamplerProxy") { - this.getApiInfo(request); - // 校验是否是全路径 - if (!request.url || (!request.url.startsWith("http://") && !request.url.startsWith("https://"))) { - this.isFullUrl = false; - } - } else if (request.type === "scenario") { - this.getScenario(request); - } - } else { - if (request.type === "HTTPSamplerProxy") { - // 校验是否是全路径 - - if (request.enable) { - if (!request.url || (!request.url.startsWith("http://") && !request.url.startsWith("https://"))) { - this.isFullUrl = false; - } - } - } - } - if (scenarioDefinition[i].hashTree != undefined && scenarioDefinition[i].hashTree.length > 0) { - this.recursiveSorting(scenarioDefinition[i].hashTree); - } - } - }, checkEnv() { let sign = true; this.isFullUrl = true; @@ -244,9 +128,6 @@ export default { } else { sign = false; } - // 校验是否全是全路径 - //this.checkFullUrl(data); - //sign = this.isFullUrl; } if (!sign) {