|
@@ -20,7 +20,7 @@
|
|
|
|
|
|
import { getToken } from '@/utils/token'
|
|
|
import { ElNotification } from 'element-plus'
|
|
|
-
|
|
|
+import useNoticeStore from '@/stores/modules/notice'
|
|
|
let socketUrl: any = '' // socket地址
|
|
|
let websocket: any = null // websocket 实例
|
|
|
let heartTime: any = null // 心跳定时器实例
|
|
@@ -35,7 +35,7 @@ export const initWebSocket = (url: any) => {
|
|
|
}
|
|
|
socketUrl = url
|
|
|
// 初始化 websocket
|
|
|
- websocket = new WebSocket(url + '?Authorization=Bearer ' + getToken() + '&clientid=' + import.meta.env.VITE_APP_CLIENT_ID)
|
|
|
+ websocket = new WebSocket(url + '?Authorization=Bearer ' + getToken() + '&clientId=' + import.meta.env.VITE_APP_CLIENT_ID)
|
|
|
websocketOnopen()
|
|
|
websocketOnmessage()
|
|
|
websocketOnerror()
|
|
@@ -122,11 +122,11 @@ export const websocketOnmessage = () => {
|
|
|
if (e.data.indexOf('ping') > 0) {
|
|
|
return
|
|
|
}
|
|
|
- // useNoticeStore().addNotice({
|
|
|
- // message: e.data,
|
|
|
- // read: false,
|
|
|
- // time: new Date().toLocaleString()
|
|
|
- // })
|
|
|
+ useNoticeStore().addNotice({
|
|
|
+ message: e.data,
|
|
|
+ read: false,
|
|
|
+ time: new Date().toLocaleString()
|
|
|
+ })
|
|
|
ElNotification({
|
|
|
title: '消息',
|
|
|
message: e.data,
|