From e2a78debcfdc0dc44fd742d27fcbfc32ce801391 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Wed, 24 Aug 2022 19:31:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AB=99=E5=86=85=E9=80=9A=E7=9F=A5=E5=BC=B9?= =?UTF-8?q?=E6=A1=86=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1016011 --user=刘瑞斌 【消息通知】执行接口case时有时收到多条系统站内通知,有时不会弹出站内通知 https://www.tapd.cn/55049933/s/1233494 --- .../java/io/metersphere/websocket/NotificationWebSocket.java | 4 ++-- frontend/src/business/components/notice/Notification.vue | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/io/metersphere/websocket/NotificationWebSocket.java b/backend/src/main/java/io/metersphere/websocket/NotificationWebSocket.java index 87779101ca..4a96ce5d7b 100644 --- a/backend/src/main/java/io/metersphere/websocket/NotificationWebSocket.java +++ b/backend/src/main/java/io/metersphere/websocket/NotificationWebSocket.java @@ -17,7 +17,7 @@ import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.ConcurrentHashMap; -@ServerEndpoint("/notification/count/{userId}") +@ServerEndpoint("/notification/count/{userId}/{random}") @Component public class NotificationWebSocket { private static NotificationService notificationService; @@ -32,7 +32,7 @@ public class NotificationWebSocket { * 开启连接的操作 */ @OnOpen - public void onOpen(@PathParam("userId") String userId, Session session) { + public void onOpen(@PathParam("userId") String userId, @PathParam("random") double random, Session session) { Timer timer = new Timer(true); NotificationCenter task = new NotificationCenter(session, userId); timer.schedule(task, 0, 10 * 1000); diff --git a/frontend/src/business/components/notice/Notification.vue b/frontend/src/business/components/notice/Notification.vue index d4a3cd50e7..156a25f011 100644 --- a/frontend/src/business/components/notice/Notification.vue +++ b/frontend/src/business/components/notice/Notification.vue @@ -99,7 +99,7 @@ export default { if (window.location.protocol === 'https:') { protocol = "wss://"; } - const uri = protocol + window.location.host + "/notification/count/" + getCurrentUserId(); + const uri = protocol + window.location.host + "/notification/count/" + getCurrentUserId() + "/" + Math.random(); this.websocket = new WebSocket(uri); this.websocket.onmessage = this.onMessage; this.websocket.onopen = this.onOpen; @@ -163,8 +163,6 @@ export default { type: 'info', message: message, }); - // 弹出之后标记成已读 - this.$get('/notification/read/' + d.id); this.noticeShow = true; }); });