From fb17de6493221d9d911cff2a87a82f7eae9faddc Mon Sep 17 00:00:00 2001 From: HenryDu8133 <813367384@qq.com> Date: Mon, 17 Aug 2026 17:55:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(cablemanager):=20=E4=BF=AE=E5=A4=8D=20cable?= =?UTF-8?q?manager=20=E6=97=A0=E6=B3=95=E6=93=8D=E4=BD=9C=20+=20=E4=B8=80?= =?UTF-8?q?=E7=9B=B4=E5=88=B7=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98=20-=20?= =?UTF-8?q?=E6=A0=B9=E5=9B=A01:=20GET=20/api/audio-cable-groups=20?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E7=AB=AF=E8=BF=94=E5=9B=9E=20{groups:=20list?= =?UTF-8?q?}=EF=BC=8C=E4=BD=86=E5=89=8D=E7=AB=AF=20loadGroups()=20?= =?UTF-8?q?=E8=AF=BB=20data.audioCableGroups=20=E2=86=92=20=E6=B0=B8?= =?UTF-8?q?=E8=BF=9C=E8=AF=BB=E5=88=B0=20undefined=20=E2=86=92=20=E5=A7=8B?= =?UTF-8?q?=E7=BB=88=E7=A9=BA=E5=88=97=E8=A1=A8=20=20=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?:=20=E6=9C=8D=E5=8A=A1=E7=AB=AF=20L3447=20=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=20groups=20=E5=92=8C=20audioCableGroups=20?= =?UTF-8?q?=E4=B8=A4=E4=B8=AA=E5=88=AB=E5=90=8D=EF=BC=9B=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=20loadGroups()=20=E4=BC=98=E5=85=88=E8=AF=BB=20audioCableGroup?= =?UTF-8?q?s=EF=BC=8C=E4=B8=8D=E5=AD=98=E5=9C=A8=E5=88=99=E5=9B=9E?= =?UTF-8?q?=E9=80=80=20groups=20-=20=E6=A0=B9=E5=9B=A02:=20WebSocket=20onm?= =?UTF-8?q?essage=20=E6=94=B6=E5=88=B0=20init=5Fstate/state=5Fupdate=20?= =?UTF-8?q?=E7=AB=8B=E5=8D=B3=20reloadAll(=E5=B8=A6=20toast)=EF=BC=8C?= =?UTF-8?q?=E8=8B=A5=E4=BA=8B=E4=BB=B6=E9=A2=91=E7=B9=81=E4=BC=9A=E5=8F=8D?= =?UTF-8?q?=E5=A4=8D=20re-render=20+=20=E8=BF=9E=E5=BC=B9=E3=80=8E?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=B7=B2=E5=88=B7=E6=96=B0=E3=80=8Ftoast=20?= =?UTF-8?q?=E2=86=92=20=E7=9C=8B=E8=B5=B7=E6=9D=A5=E4=B8=80=E7=9B=B4?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E4=B8=94=E8=BE=93=E5=85=A5=E6=A1=86=E6=80=BB?= =?UTF-8?q?=E8=A2=AB=E9=87=8D=E7=BD=AE=20=20=20=E4=BF=AE=E5=A4=8D:=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=20scheduleAutoReload()=20=E8=8A=82=E6=B5=81?= =?UTF-8?q?=EF=BC=88=E4=B8=A4=E6=AC=A1=E8=87=AA=E5=8A=A8=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E4=B9=8B=E9=97=B4=E8=87=B3=E5=B0=91=E9=97=B4=E9=9A=94=20900ms?= =?UTF-8?q?=EF=BC=89=EF=BC=9B=E4=B8=94=E8=87=AA=E5=8A=A8=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E8=B5=B0=20reloadAll({silent:true})=20?= =?UTF-8?q?=E4=B8=8D=E5=BC=B9=E6=88=90=E5=8A=9F/=E5=A4=B1=E8=B4=A5=20toast?= =?UTF-8?q?=EF=BC=9B=E4=BB=85=E7=94=A8=E6=88=B7=E7=82=B9=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E6=89=8D=E5=BC=B9=E6=8F=90=E7=A4=BA=20-=20?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=AE=9E=E6=B5=8B:=20PORT=3D8999=20=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=20server=20=E5=90=8E=20/api/stations=20=E2=86=92=20{s?= =?UTF-8?q?uccess:true,=20stations:[]}=EF=BC=8C/api/audio-cable-groups=20?= =?UTF-8?q?=E2=86=92=20{success:true,=20groups:[],=20audioCableGroups:[]}?= =?UTF-8?q?=EF=BC=8C=E4=B8=A4=E4=B8=AA=E7=AB=AF=E7=82=B9=E5=9D=87=20200=20?= =?UTF-8?q?=E4=B8=94=E5=93=8D=E5=BA=94=E7=BB=93=E6=9E=84=E5=90=AB=E5=8F=8C?= =?UTF-8?q?=E5=88=AB=E5=90=8D=20key=20-=20APP=5FVERSION=5FTEXT=20bump=20?= =?UTF-8?q?=E5=88=B0=20v1.0.109?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CloudServer/public/cablemanager.html | 30 +++++++++++++++++++++++----- CloudServer/server.js | 2 +- station_broadcast.lua | 2 +- 3 files changed, 27 insertions(+), 7 deletions(-) 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",