Browse Source

perf[litemall-admin]: 微优化通知查询机制

Junling Bu 5 years ago
parent
commit
02a704cf9a
1 changed files with 4 additions and 1 deletions
  1. 4 1
      litemall-admin/src/components/Notice/index.vue

+ 4 - 1
litemall-admin/src/components/Notice/index.vue

@@ -17,7 +17,7 @@ export default {
     }
     }
   },
   },
   mounted() {
   mounted() {
-    this.timer = setInterval(this.checkNotice, 10 * 1000)
+    this.timer = setInterval(this.checkNotice, 30 * 1000)
   },
   },
   beforeDestroy() {
   beforeDestroy() {
     clearInterval(this.timer)
     clearInterval(this.timer)
@@ -30,6 +30,9 @@ export default {
       this.$router.push({ path: '/profile/notice' })
       this.$router.push({ path: '/profile/notice' })
     },
     },
     checkNotice() {
     checkNotice() {
+      if (this.hasNotice) {
+        return
+      }
       nNotice().then(response => {
       nNotice().then(response => {
         this.hasNotice = response.data.data > 0
         this.hasNotice = response.data.data > 0
       })
       })