diff --git a/CloudServer/public/cablemanager.html b/CloudServer/public/cablemanager.html index d47a316..4bfd57d 100644 --- a/CloudServer/public/cablemanager.html +++ b/CloudServer/public/cablemanager.html @@ -1499,7 +1499,7 @@ const res = await fetch('/api/audio-cable-groups'); const data = await res.json(); if (data.success) { - audioCableGroups = data.audioCableGroups || []; + audioCableGroups = Array.isArray(data.audioCableGroups) ? data.audioCableGroups : (Array.isArray(data.groups) ? data.groups : []); } else { throw new Error(data.message || '加载分组失败'); } @@ -1516,7 +1516,8 @@ if (!Array.isArray(stations)) stations = []; } - async function reloadAll() { + async function reloadAll(options) { + const silent = !!(options && options.silent); try { await Promise.all([loadGroups(), loadStations()]); renderGroupList(); @@ -1530,9 +1531,9 @@ renderDualLists(); } } - showToast('成功', '数据已刷新', 'success'); + if (!silent) showToast('成功', '数据已刷新', 'success'); } catch (e) { - showToast('错误', e?.message || String(e), 'error'); + if (!silent) showToast('错误', e?.message || String(e), 'error'); } } @@ -1558,6 +1559,25 @@ } let ws; + let _autoReloadTimer = 0; + let _autoReloadPending = false; + function scheduleAutoReload() { + _autoReloadPending = true; + const now = Date.now(); + const wait = Math.max(0, 900 - (now - _autoReloadTimer)); + const fire = () => { + if (!_autoReloadPending) return; + _autoReloadPending = false; + _autoReloadTimer = Date.now(); + reloadAll({ silent: true }).catch(() => {}); + }; + if (wait === 0) { + Promise.resolve().then(fire); + } else { + clearTimeout(scheduleAutoReload._t); + scheduleAutoReload._t = setTimeout(fire, wait); + } + } function connectWebSocket() { try { const wsProto = window.location.protocol === 'https:' ? 'wss' : 'ws'; @@ -1572,7 +1592,7 @@ try { const data = JSON.parse(event.data); if (data.type === 'init_state' || data.type === 'state_update') { - reloadAll().catch(() => {}); + scheduleAutoReload(); } } catch (e) {} }; diff --git a/CloudServer/server.js b/CloudServer/server.js index 8fc4558..baa19a1 100644 --- a/CloudServer/server.js +++ b/CloudServer/server.js @@ -3444,7 +3444,7 @@ app.get('/api/audio-cable-groups', (req, res) => { }; })() })); - res.json({ success: true, groups: list }); + res.json({ success: true, groups: list, audioCableGroups: list }); }); app.post('/api/audio-cable-groups', express.json(), (req, res) => { diff --git a/station_broadcast.lua b/station_broadcast.lua index df7f45d..8617d38 100644 --- a/station_broadcast.lua +++ b/station_broadcast.lua @@ -1,6 +1,6 @@ -- 1. Configuration & Constants -local APP_VERSION_TEXT = "v1.0.108" +local APP_VERSION_TEXT = "v1.0.109" local CONFIG = { CLOUD_URL = "ws://stabadmin.fse-media.group",