yusheng 1 anno fa
parent
commit
863c169d8c
1 ha cambiato i file con 8 aggiunte e 12 eliminazioni
  1. 8 12
      src/layout/components/header-notice.vue

+ 8 - 12
src/layout/components/header-notice.vue

@@ -121,11 +121,11 @@
 <script>
 <script>
   import {
   import {
     getUnreadNotice,
     getUnreadNotice,
-    getUnreadNotifyMessageCountAPI,
     updateAllNotifyMessageReadAPI,
     updateAllNotifyMessageReadAPI,
     updateNotifyMessageReadByIdAPI
     updateNotifyMessageReadByIdAPI
   } from '@/api/layout';
   } from '@/api/layout';
   import { getToken } from '@/utils/token-util';
   import { getToken } from '@/utils/token-util';
+  import { init } from '@/utils/common.js';
 
 
   export default {
   export default {
     data() {
     data() {
@@ -164,9 +164,13 @@
     },
     },
     created() {
     created() {
       if (getToken()) {
       if (getToken()) {
-        this.getCount();
+        let url = 'ws://'+window.location.host+'/websocket/UnreadNotifyMessageCount?token='+getToken()
+        let socket = new WebSocket(url);
+        socket.onmessage = (event) => {
+          console.log(event.data)
+          this.noticeCount = event.data * 1 || 0;
+        };
       }
       }
-      console.log('123123');
     },
     },
     methods: {
     methods: {
       /* 查询数据 */
       /* 查询数据 */
@@ -174,15 +178,7 @@
         this.notice = await getUnreadNotice();
         this.notice = await getUnreadNotice();
         this.notice = this.notice.slice(0, 15);
         this.notice = this.notice.slice(0, 15);
       },
       },
-      /* 查询条数 */
-      async getCount() {
-        clearInterval(this.timer);
-        let count = await getUnreadNotifyMessageCountAPI();
-        this.noticeCount = count * 1 || 0;
-        this.timer = setInterval(() => {
-          this.getCount();
-        }, 5000);
-      },
+    
 
 
       /* 清空通知 */
       /* 清空通知 */
       async clearNotice(item = {}, index) {
       async clearNotice(item = {}, index) {