From 4807ccd91b86b1ef13c17d48dcd585bdf1e9833e Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Fri, 24 Dec 2021 14:36:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=A1=B9=E7=9B=AE=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E4=BB=A3=E7=A0=81=E7=89=87=E6=AE=B5?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=97=B6=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1009212 --user=lyh 自定义代码片段测试时SQL报错 https://www.tapd.cn/55049933/s/1086695 --- .../service/CustomFunctionService.java | 1 + .../project/menu/function/FunctionRun.vue | 23 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/io/metersphere/service/CustomFunctionService.java b/backend/src/main/java/io/metersphere/service/CustomFunctionService.java index a3b0617952..e6f2dd6028 100644 --- a/backend/src/main/java/io/metersphere/service/CustomFunctionService.java +++ b/backend/src/main/java/io/metersphere/service/CustomFunctionService.java @@ -116,6 +116,7 @@ public class CustomFunctionService { } public MsExecResponseDTO run(RunDefinitionRequest request) { + request.setDebug(true); return apiDefinitionService.run(request, new LinkedList<>()); } } diff --git a/frontend/src/business/components/project/menu/function/FunctionRun.vue b/frontend/src/business/components/project/menu/function/FunctionRun.vue index 8cd05b3202..ac11c9b4e3 100644 --- a/frontend/src/business/components/project/menu/function/FunctionRun.vue +++ b/frontend/src/business/components/project/menu/function/FunctionRun.vue @@ -57,6 +57,27 @@ export default { this.$emit('runRefresh', data); } }, + onDebugMessage(e) { + if (e.data && e.data.startsWith("result_")) { + try { + let data = e.data.substring(7); + this.websocket.close(); + this.$emit('runRefresh', JSON.parse(data)); + } catch (e) { + this.websocket.close(); + this.$emit('runRefresh', ""); + } + } + }, + debugSocket() { + let protocol = "ws://"; + if (window.location.protocol === 'https:') { + protocol = "wss://"; + } + const uri = protocol + window.location.host + "/ws/" + this.reportId; + this.websocket = new WebSocket(uri); + this.websocket.onmessage = this.onDebugMessage; + }, sort(stepArray) { if (stepArray) { for (let i in stepArray) { @@ -94,7 +115,7 @@ export default { reqObj.reportId = this.reportId; this.$post(url, reqObj, res => { this.requestResult = res.data; - this.initWebSocket(); + this.debugSocket(); }, () => { this.$emit('errorRefresh', {}); })