From 245149da6b8076b2d7ea4d17394d450f43206ebf Mon Sep 17 00:00:00 2001 From: wuHakureReimu Date: Sat, 27 Dec 2025 15:59:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=95=AA=E8=8C=84=E9=92=9Fse?= =?UTF-8?q?ttings-content=E7=95=8C=E9=9D=A2=E7=9A=84=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E6=9D=A1=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/PomodoroTimer.vue | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/components/PomodoroTimer.vue b/src/components/PomodoroTimer.vue index 415ccfa..7279697 100644 --- a/src/components/PomodoroTimer.vue +++ b/src/components/PomodoroTimer.vue @@ -34,7 +34,7 @@ -
+
{{ statusText }} @@ -231,8 +231,29 @@ const onUIMouseEnter = () => { setHoveringUI(true) } const onUIMouseLeave = () => { setHoveringUI(false) } const onUITouchStart = () => { setHoveringUI(true) } const onUITouchEnd = () => { setHoveringUI(false) } + +// settings-content的scrolling bar控制 +const settingsContentRef = ref(null) +let removeScrollListener = null +const setupScrollDetection = () => { + const contentElement = settingsContentRef.value + let timer = null + const handleScroll = () => { clearTimeout(timer); contentElement.classList.add('scrolling'); timer = setTimeout(() => contentElement.classList.remove('scrolling'), 350) } + contentElement.addEventListener('scroll', handleScroll) + return () => { contentElement.removeEventListener('scroll', handleScroll); clearTimeout(timer) } +} +// 事件监听器的生命周期 +watch(showSettings, (newVal) => { + if (newVal) { setTimeout(() => { if (removeScrollListener) removeScrollListener(); removeScrollListener = setupScrollDetection() }, 200) } + else if (removeScrollListener) { removeScrollListener(); removeScrollListener = null } +}) + onMounted(() => { if ('Notification' in window && Notification.permission === 'default') Notification.requestPermission(); timeInterval = setInterval(() => { currentTime.value = new Date() }, 1000) }) -onUnmounted(() => { if (timer) clearInterval(timer); if (timeInterval) clearInterval(timeInterval) }) +onUnmounted(() => { + if (timer) clearInterval(timer) + if (timeInterval) clearInterval(timeInterval) + if (removeScrollListener) removeScrollListener() +})