Ver código fonte

是否开启等待

zhengnaiwen_citu 3 meses atrás
pai
commit
fce8ace084
1 arquivos alterados com 9 adições e 14 exclusões
  1. 9 14
      src/layout/components/LayoutNotification.vue

+ 9 - 14
src/layout/components/LayoutNotification.vue

@@ -105,19 +105,9 @@ export default {
     ...mapGetters(['userInfo'])
   },
   created () {
-    this.getUnread()
-    // if (this.timer) {
-    //   clearInterval(this.timer)
-    // }
-    // this.timer = setInterval(() => {
-    //   this.getUnread()
-    // }, 3000)
+    // 初次获取未读消息
+    this.getUnread(false)
   },
-  // beforeDestroy () {
-  //   if (this.timer) {
-  //     clearInterval(this.timer)
-  //   }
-  // },
   methods: {
     onCommand (index) {
       this.menuActive = index
@@ -137,10 +127,15 @@ export default {
       await this.onInit()
       this.loading = false
     },
-    async getUnread () {
+    /**
+     * 获取未读数,后端卡等待时间
+     * @param wait 是否等待
+     */
+    async getUnread (wait = true) {
       try {
         const { data } = await sendUnreadCount({
-          unreadCount: this.unreadTotal
+          unreadCount: this.unreadTotal,
+          wait
         })
         this.unreadTotal = data
       } catch (error) {