|
|
|
@ -115,18 +115,18 @@ export const sendMsg = (data: any) => {
|
|
|
|
// socket 接收数据
|
|
|
|
// socket 接收数据
|
|
|
|
export const websocketonmessage = () => {
|
|
|
|
export const websocketonmessage = () => {
|
|
|
|
websocket.onmessage = function (e: any) {
|
|
|
|
websocket.onmessage = function (e: any) {
|
|
|
|
const msg = JSON.parse(e.data) as any;
|
|
|
|
if (e.data.indexOf('heartbeat') > 0) {
|
|
|
|
if (msg.type === 'heartbeat') {
|
|
|
|
|
|
|
|
resetHeart();
|
|
|
|
resetHeart();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (msg.type === 'ping') {
|
|
|
|
if (e.data.indexOf('ping') > 0) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
addNotice({
|
|
|
|
addNotice({
|
|
|
|
message: msg,
|
|
|
|
message: e.data,
|
|
|
|
read: false,
|
|
|
|
read: false,
|
|
|
|
time: new Date().toLocaleString()
|
|
|
|
time: new Date().toLocaleString()
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return msg;
|
|
|
|
ElMessage.success(e.data);
|
|
|
|
|
|
|
|
return e.data;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|