From 034b464a6534a62ef8a717ecb1bf34df8f100d06 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Thu, 15 Apr 2021 11:57:35 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95=E6=8A=A5=E5=91=8A=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=95=B0=E6=8D=AE=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=8F=AF=E5=8A=A8=E6=80=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/metersphere/websocket/ReportWebSocket.java | 2 +- .../performance/report/PerformanceReportView.vue | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/io/metersphere/websocket/ReportWebSocket.java b/backend/src/main/java/io/metersphere/websocket/ReportWebSocket.java index 8bf034ad75..8f7abf4ccb 100644 --- a/backend/src/main/java/io/metersphere/websocket/ReportWebSocket.java +++ b/backend/src/main/java/io/metersphere/websocket/ReportWebSocket.java @@ -65,7 +65,7 @@ public class ReportWebSocket { } refreshTimes.put(session, refreshTime); try { - session.getBasicRemote().sendText("refresh-" + 0); + session.getBasicRemote().sendText("refresh-" + Math.random()); } catch (IOException e) { LogUtil.error(e.getMessage(), e); } diff --git a/frontend/src/business/components/performance/report/PerformanceReportView.vue b/frontend/src/business/components/performance/report/PerformanceReportView.vue index 75956d7b13..d2e05e5574 100644 --- a/frontend/src/business/components/performance/report/PerformanceReportView.vue +++ b/frontend/src/business/components/performance/report/PerformanceReportView.vue @@ -159,7 +159,7 @@ export default { dialogFormVisible: false, reportExportVisible: false, testPlan: {testResourcePoolId: null}, - refreshTime: '20', + refreshTime: localStorage.getItem("reportRefreshTime") || "20", refreshTimes: [ {value: '1', label: '1s'}, {value: '3', label: '3s'}, @@ -273,6 +273,7 @@ export default { }); }, onOpen() { + this.refresh(); // window.console.log("socket opening."); }, onError(e) { @@ -375,8 +376,11 @@ export default { }, refresh() { if (this.status === 'Running') { - this.websocket.send(this.refreshTime); + if (this.websocket && this.websocket.readyState === 1) { + this.websocket.send(this.refreshTime); + } } + localStorage.setItem("reportRefreshTime", this.refreshTime); } }, created() { @@ -397,8 +401,6 @@ export default { this.reportId = to.path.split('/')[4]; this.getReport(this.reportId); this.initBreadcrumb((response) => { - let data = response.data; - this.checkReportStatus(data.status); this.initReportTimeInfo(); }); this.initWebSocket();