فهرست منبع

3.0.99 消息推送刷新系统通知数量

liuyanpeng 2 سال پیش
والد
کامیت
12813f9265
4فایلهای تغییر یافته به همراه37 افزوده شده و 26 حذف شده
  1. 1 1
      package.json
  2. 1 1
      public/index-release.html
  3. 24 14
      src/common/pushMessage.js
  4. 11 10
      src/workflow/Approve.vue

+ 1 - 1
package.json

@@ -1,7 +1,7 @@
 {
   "name": "client-base-v4",
   "description": "Leanwo Prodog Client",
-  "version": "3.0.98",
+  "version": "3.0.99",
   "author": "yangzhijie1488 <yangzhijie1488@163.com>",
   "scripts": {
     "dev": "cross-env webpack serve --config ./webpack.dev.js",

+ 1 - 1
public/index-release.html

@@ -78,7 +78,7 @@
 <body>
 	<div id="app">
 	</div>
-
+	<div id="refreshCount"></div>
 	<script defer="defer" nonce="*NONCE_TOKEN*"  src="../static/js/echarts.min.js"></script>
 	<!-- <script src="../static/js/fullscreen-api.js"></script> -->
 	<!-- <script src="../static/js/problem-feedback-api.js"></script> -->

+ 24 - 14
src/common/pushMessage.js

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

+ 11 - 10
src/workflow/Approve.vue

@@ -97,15 +97,15 @@ export default {
     };
   },
 
-  watch: {
-    $route: function () {
-      var functionType = this.$route.query.functionType;
-      if (functionType) {
-        this.functionType = functionType;
-      }
-      this.initQueryParamter();
-    },
-  },
+  // watch: {
+  //   $route: function () {
+  //     var functionType = this.$route.query.functionType;
+  //     if (functionType) {
+  //       this.functionType = functionType;
+  //     }
+  //     this.initQueryParamter();
+  //   },
+  // },
 
   mounted: function () {
     var _self = this;
@@ -180,7 +180,8 @@ export default {
         url = url.substring(0, index);
       }
       url = url + '?functionType=' + _self.functionType;
-      window.location.href = url;
+      // window.location.href = url;
+      this.$router.push('/desktop/approve?functionType=' + _self.functionType);
     },
 
   },