浏览代码

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

Junling Bu 5 年之前
父节点
当前提交
02a704cf9a
共有 1 个文件被更改,包括 4 次插入1 次删除
  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() {
-    this.timer = setInterval(this.checkNotice, 10 * 1000)
+    this.timer = setInterval(this.checkNotice, 30 * 1000)
   },
   beforeDestroy() {
     clearInterval(this.timer)
@@ -30,6 +30,9 @@ export default {
       this.$router.push({ path: '/profile/notice' })
     },
     checkNotice() {
+      if (this.hasNotice) {
+        return
+      }
       nNotice().then(response => {
         this.hasNotice = response.data.data > 0
       })