From c29dd9324369feb30399e413451dea1851e9c98a Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Fri, 28 Aug 2020 17:24:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E5=86=8D=E6=AC=A1=E6=89=A7=E8=A1=8C=E6=97=B6?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=97=B6=E9=97=B4=E7=8A=B6=E6=80=81=E6=A3=80?= =?UTF-8?q?=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/PerformanceReportView.vue | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/frontend/src/business/components/performance/report/PerformanceReportView.vue b/frontend/src/business/components/performance/report/PerformanceReportView.vue index 6492b79630..34b33e0bd0 100644 --- a/frontend/src/business/components/performance/report/PerformanceReportView.vue +++ b/frontend/src/business/components/performance/report/PerformanceReportView.vue @@ -142,6 +142,10 @@ export default { } }, initReportTimeInfo() { + if (this.status === 'Starting') { + this.clearData(); + return; + } if (this.reportId) { this.result = this.$get("/performance/report/content/report_time/" + this.reportId) .then(res => { @@ -155,7 +159,7 @@ export default { } }).catch(() => { this.clearData(); - }) + }); } }, initWebSocket() { @@ -226,10 +230,15 @@ export default { onMessage(e) { this.$set(this.report, "refresh", e.data); // 触发刷新 this.$set(this.report, "status", 'Running'); + this.status = 'Running'; this.initReportTimeInfo(); window.console.log('receive a message:', e.data); }, onClose(e) { + if (e.code === 1005) { + // 强制删除之后关闭socket,不用刷新report + return; + } this.$set(this.report, "refresh", Math.random()); // 触发刷新 this.$set(this.report, "status", 'Completed'); this.initReportTimeInfo(); @@ -262,9 +271,6 @@ export default { }); }, - beforeDestroy() { - this.websocket.close() //离开路由之后断开websocket连接 - }, watch: { '$route'(to) { if (to.name === "perReportView") { @@ -295,6 +301,9 @@ export default { }); } + } else { + console.log("close socket."); + this.websocket.close() //离开路由之后断开websocket连接 } } }