diff --git a/server.js b/server.js index 8caf7b4..e362c67 100644 --- a/server.js +++ b/server.js @@ -136,11 +136,10 @@ function startCarouselTimer() { const startTime = parseInt(getConfig('current_group_start_time') || '0'); const currentGroup = groups[idx]; - if (currentGroup.display_seconds === 0) { - broadcastState(); - return; - } + // 无限时分组,不需要切换 + if (currentGroup.display_seconds === 0) return; + // 首次启动,记录开始时间并广播 if (startTime === 0) { setConfig('current_group_start_time', Math.floor(Date.now() / 1000)); broadcastState(); @@ -150,12 +149,13 @@ function startCarouselTimer() { const now = Math.floor(Date.now() / 1000); const elapsed = now - startTime; + // 时间到了,切换分组并广播 if (elapsed >= currentGroup.display_seconds) { const nextIdx = findNextGroupIndex(groups, idx); setConfig('current_group_index', nextIdx); setConfig('current_group_start_time', Math.floor(Date.now() / 1000)); + broadcastState(); } - broadcastState(); }, 1000); }