|
|
@@ -12,10 +12,8 @@ export default {
|
|
|
timer: null,
|
|
|
source: null,
|
|
|
isSound: false,
|
|
|
- openDate: null,
|
|
|
allMessage: [],
|
|
|
webSocket: null,
|
|
|
- messageDate: null,
|
|
|
notificationId: null,
|
|
|
|
|
|
|
|
|
@@ -155,7 +153,7 @@ export default {
|
|
|
notification.open({
|
|
|
key: messageData.uuid,
|
|
|
message: messageData.content.title,
|
|
|
- description: messageData.content.description,
|
|
|
+ description: '您有一条待处理消息',
|
|
|
icon: () =>
|
|
|
h(MessageTwoTone, {
|
|
|
style: 'color: #108ee9',
|
|
|
@@ -254,7 +252,7 @@ export default {
|
|
|
messageModal: function () {
|
|
|
const _self = this;
|
|
|
Modal.warning({
|
|
|
- okText: '我知道了',
|
|
|
+ okText: '确认',
|
|
|
title: '温馨提示',
|
|
|
content: '您的浏览器设置,提示音无法自动播放,请您点击【确认】按钮,可以自动播放提示音。',
|
|
|
onOk() {
|
|
|
@@ -263,7 +261,19 @@ export default {
|
|
|
},
|
|
|
});
|
|
|
},
|
|
|
-
|
|
|
+ // 触发仪表盘数量更新事件
|
|
|
+ executionEvent: function () {
|
|
|
+ // 获取刷新元素
|
|
|
+ const refreshElement = document.querySelector('#refreshCount');
|
|
|
+ // 自定义事件
|
|
|
+ const customEvent = new CustomEvent('evt');
|
|
|
+ // 触发事件
|
|
|
+ window.refreshTimer = setInterval(function () {
|
|
|
+ refreshElement.dispatchEvent(customEvent);
|
|
|
+ clearInterval(window.refreshTimer);
|
|
|
+ window.refreshTimer = null;
|
|
|
+ }, 10000);
|
|
|
+ },
|
|
|
// 打开websocket
|
|
|
openWebSocket: function () {
|
|
|
const _self = this;
|
|
|
@@ -281,16 +291,9 @@ export default {
|
|
|
}
|
|
|
_self.webSocket = new WebSocket(websocketUrl, [token]);
|
|
|
_self.webSocket.onopen = function () {
|
|
|
- _self.openDate = new Date().getTime();
|
|
|
console.log('websocket打开');
|
|
|
};
|
|
|
_self.webSocket.onmessage = function (message) {
|
|
|
- _self.messageDate = new Date().getTime();
|
|
|
- const difference = Math.abs(_self.messageDate - _self.openDate);
|
|
|
- if (difference > 10000) {
|
|
|
- // 刷新数量
|
|
|
- console.log('刷新数量');
|
|
|
- }
|
|
|
let taskData = JSON.parse(message.data);
|
|
|
console.log('websocket 收到信息 : ' + taskData);
|
|
|
if (taskData) {
|
|
|
@@ -299,6 +302,10 @@ export default {
|
|
|
if (_self.timer == null) {
|
|
|
_self.triggerNotification();
|
|
|
}
|
|
|
+ if (!window.refreshTimer) {
|
|
|
+ _self.executionEvent();
|
|
|
+ }
|
|
|
+ _self.webSocket.send(message.data);
|
|
|
};
|
|
|
_self.webSocket.onclose = function () {
|
|
|
console.log('websocket关闭');
|
|
|
@@ -313,10 +320,13 @@ export default {
|
|
|
// 注销后关闭websocket和循环
|
|
|
closeWebsocket: function () {
|
|
|
const _self = this;
|
|
|
- if (_self.webSocket && _self.timer) {
|
|
|
- _self.timer = null;
|
|
|
+ if (_self.webSocket) {
|
|
|
_self.webSocket.close();
|
|
|
+ clearInterval(_self.timer);
|
|
|
+ clearInterval(window.refreshTimer);
|
|
|
+ _self.timer = null;
|
|
|
_self.webSocket = null;
|
|
|
+ window.refreshTimer = null;
|
|
|
_self.allMessage.splice(0, _self.allMessage.length);
|
|
|
notification.close(_self.notificationId);
|
|
|
}
|