定时器相关

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)

  

猜你喜欢

转载自www.cnblogs.com/MonaSong/p/8986986.html