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; }); });