Skip to content

Commit 2dd4535

Browse files
committed
feat: 添加定时器过期检查功能 优化顶部定时点击
1 parent f5f0dbb commit 2dd4535

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/renderer/components/player/SleepTimerTop.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ const { sleepTimer } = storeToRefs(playerStore);
2020
const hasActiveSleepTimer = computed(() => playerStore.hasSleepTimerActive);
2121
const refreshTrigger = ref(0);
2222
23+
// 检查定时器是否已结束
24+
const checkTimerExpired = () => {
25+
if (sleepTimer.value.type === 'time' && sleepTimer.value.endTime) {
26+
const now = Date.now();
27+
if (now >= sleepTimer.value.endTime) {
28+
playerStore.clearSleepTimer();
29+
}
30+
}
31+
}
32+
33+
// 在组件挂载时检查定时器状态
34+
onMounted(() => {
35+
checkTimerExpired();
36+
});
37+
38+
2339
// 倒计时显示
2440
const formattedRemainingTime = computed(() => {
2541
// 依赖刷新触发器强制更新
@@ -84,7 +100,7 @@ function stopTimerUpdate() {
84100
}
85101
86102
const handleShowTimer = () => {
87-
playerStore.showSleepTimer = true;
103+
playerStore.showSleepTimer = !playerStore.showSleepTimer;
88104
};
89105
90106
// 播放器卸载时清除定时器

0 commit comments

Comments
 (0)