From 04612747d1fe0368bad4bb0a4cdce99d72911697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BE=B9=E7=BC=98=E5=9D=90=E6=A0=87?= Date: Thu, 8 Feb 2024 17:05:12 +0800 Subject: [PATCH] Update WaterFall.vue --- src/components/WaterFall.vue | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/components/WaterFall.vue b/src/components/WaterFall.vue index 6f7e717..907899e 100644 --- a/src/components/WaterFall.vue +++ b/src/components/WaterFall.vue @@ -151,7 +151,7 @@ function handleViewerKeyDown(event) {// * 查看器内部 检查是否按下了 let theCycleUpdateInterval function turnOnCycleUpdate() { console.log('Turn on cycleUpdate'); - theCycleUpdateInterval = window.setInterval(handleLoadMore, 500); + theCycleUpdateInterval = setInterval(handleLoadMore, 500); } function tEventListening() { // * 一些乱七八糟的事件的监听 @@ -175,18 +175,12 @@ function tEventListening() { // * 一些乱七八糟的事件的监听 } } }); - setStore.$subscribe((mutation: any, state) => { - // console.log(mutation, state) - // 监听 章节正则表达式变化,之后重绘书籍 - if (mutation.events.key == 'cycleUpdate') { - // console.log(state.cycleUpdate) - if (state.cycleUpdate) - turnOnCycleUpdate() - else - window.clearInterval(theCycleUpdateInterval); - } + watch(() => setStore.cycleUpdate, (newValue, oldValue) => { + if (newValue) + turnOnCycleUpdate() + else + clearInterval(theCycleUpdateInterval); }) - } // 首次加载