let timer = null; setInterval(() => { let date = new Date(); let hours = date.getHours(); if (hours < 1 || hours > 7) { // 1-8點不更新 if(timer == null){ timer = setInterval(()=>{ this.$store.dispatch('GetUnreadMessageCount') // 每隔10分鐘更新TOKEN }, 10 * 60 * 1000) } } else { clearInterval(timer); timer = null; } }, 15 * 60 * 1000)