From 1179130656b5bd74df4c43853cea6a683d468d94 Mon Sep 17 00:00:00 2001 From: HenryDu8133 <813367384@qq.com> Date: Mon, 17 Aug 2026 18:11:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(cablemanager):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=BA=BF=E7=BC=86=E5=88=86=E7=BB=84=E8=AF=A6=E6=83=85=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E6=97=B6=E6=88=90=E5=91=98=E8=A2=AB=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E6=89=93=E5=9B=9E=E4=B8=94=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E6=97=A0=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98=20=E6=A0=B9?= =?UTF-8?q?=E5=9B=A0:=20-=20cablemanager=20=E6=AF=8F=20900ms=20scheduleAut?= =?UTF-8?q?oReload()=20=E9=80=9A=E8=BF=87=20WS=20state=5Fupdate=20?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=20reloadAll({silent:true})=EF=BC=8C=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=20reloadAll=20=E5=9C=A8=20detail-view=20=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E4=B8=8B=E6=AF=8F=E6=AC=A1=E9=83=BD=E4=BC=9A=E6=97=A0?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E6=8A=8A=20detailTempMembers=20=E4=BB=8E?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E8=AF=BB=E5=9B=9E=E3=80=81selectedA?= =?UTF-8?q?vailable/selectedMembers=20=E6=B8=85=E7=A9=BA=EF=BC=8C=E6=89=80?= =?UTF-8?q?=E4=BB=A5=E7=94=A8=E6=88=B7=E5=88=9A=E6=8A=8A=E6=9F=90=E7=AB=99?= =?UTF-8?q?=E5=8F=B0=20=C2=BB=20=E5=8A=A0=E8=BF=9B=E6=88=90=E5=91=98?= =?UTF-8?q?=EF=BC=8C=E4=B8=8B=E4=B8=80=E6=AC=A1=E8=A2=AB=E5=8A=A8=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E5=88=B0=E4=BA=86=E5=B0=B1=E7=AB=8B=E5=88=BB=E8=BF=98?= =?UTF-8?q?=E5=8E=9F=EF=BC=88=E8=A7=86=E8=A7=89=E4=B8=8A=E5=B0=B1=E6=98=AF?= =?UTF-8?q?=E3=80=8C=E7=82=B9=E8=BF=87=E5=8E=BB=E5=8F=88=E8=B7=B3=E5=9B=9E?= =?UTF-8?q?=E6=9D=A5=E3=80=8D=EF=BC=89=20-=20=E4=BF=9D=E5=AD=98=20saveDeta?= =?UTF-8?q?il()=20PUT=20=E6=9C=AC=E8=BA=AB=E6=98=AF=E8=83=BD=E6=88=90?= =?UTF-8?q?=E5=8A=9F=E7=9A=84=EF=BC=88server=20PUT=20/api/audio-cable-grou?= =?UTF-8?q?ps/:id=20=E7=9A=84=20stationNames=20=E6=8E=A5=E5=8F=A3=E5=A5=91?= =?UTF-8?q?=E7=BA=A6=E6=B2=A1=E9=97=AE=E9=A2=98=EF=BC=89=EF=BC=8C=E4=BD=86?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E4=B9=8B=E5=90=8E=20loadGroups()=20=E6=8B=89?= =?UTF-8?q?=E5=AE=8C=E6=95=B0=E6=8D=AE=E5=8F=88=E7=AB=8B=E5=88=BB=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=20broadcastUpdate()=E2=86=92WS=20state=5Fupdate?= =?UTF-8?q?=E2=86=92scheduleAutoReload=E2=86=92=E5=8F=88=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=20reloadAll()=E2=86=92=E6=8A=8A=E5=88=9A=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E7=9A=84=20detailTempMembers=20=E7=94=A8=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E5=80=BC=E8=A6=86=E7=9B=96=E6=8E=89=EF=BC=8C=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=9C=8B=E8=B5=B7=E6=9D=A5=E5=B0=B1=E6=98=AF=E3=80=8C?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=97=A0=E6=95=88=E3=80=8D=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20(cablemanager.html=20reloadAll):=201.=20=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=20refresh=20=E5=89=8D=E5=90=8E=E7=9A=84=20prevGroups/?= =?UTF-8?q?prevStations=20=E5=BF=AB=E7=85=A7=EF=BC=8C=E5=8F=AA=E6=9C=89=20?= =?UTF-8?q?name/color/description=20=E6=88=96=E7=AB=99=E5=8F=B0=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E7=9C=9F=E7=9A=84=E5=8F=98=E4=BA=86=EF=BC=88groupList?= =?UTF-8?q?Changed/=20stationListChanged=EF=BC=89=E6=89=8D=E9=87=8D?= =?UTF-8?q?=E7=BB=98=E5=88=97=E8=A1=A8=E5=92=8C=E5=BF=AB=E9=80=89=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E5=BF=83=E8=B7=B3=E3=80=81lastSeen=E3=80=81t?= =?UTF-8?q?okenHolder=20=E8=BF=99=E4=BA=9B=E7=BA=AF=E7=9E=AC=E6=97=B6?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=8F=8D=E5=A4=8D=E9=87=8D=E7=BB=98=202.=20?= =?UTF-8?q?=E5=8C=BA=E5=88=86=20silent=20(=E8=A2=AB=E5=8A=A8=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=88=B7)=20vs=20=E9=9D=9E=20silent=20(=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=89=8B=E5=8A=A8=E7=82=B9=E5=88=B7=E6=96=B0)?= =?UTF-8?q?=EF=BC=9A=20=20=20=20-=20=E9=9D=9E=20silent=EF=BC=9A=E4=BF=9D?= =?UTF-8?q?=E6=8C=81=E5=8E=9F=E8=AF=AD=E4=B9=89=EF=BC=8C=E5=AE=8C=E5=85=A8?= =?UTF-8?q?=E7=94=A8=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=80=BC=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E6=89=80=E6=9C=89=E6=9C=AC=E5=9C=B0=E7=BC=96=E8=BE=91=EF=BC=88?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=B8=BB=E5=8A=A8=E7=82=B9=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E5=B0=B1=E6=98=AF=E8=A6=81=E5=9B=9E=E5=88=B0=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E7=8A=B6=E6=80=81=EF=BC=89=20=20=20=20-=20si?= =?UTF-8?q?lent=EF=BC=9A=20=20=20=20=20=20*=20=E5=8F=AA=E5=9C=A8=20metaCha?= =?UTF-8?q?nged=20=E6=97=B6=E5=90=8C=E6=AD=A5=20name/description/color?= =?UTF-8?q?=EF=BC=88=E5=B9=B6=E4=B8=94=E4=B8=8D=E6=8A=A2=E7=84=A6=E7=82=B9?= =?UTF-8?q?=E7=9A=84=20input=EF=BC=8C=E9=81=BF=E5=85=8D=E6=AD=A3=E5=9C=A8?= =?UTF-8?q?=E6=89=93=E5=AD=97=E8=A2=AB=E9=87=8D=E7=BD=AE=EF=BC=89=20=20=20?= =?UTF-8?q?=20=20=20*=20=E5=8F=AA=E5=9C=A8=20membersChanged=EF=BC=88?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=20stationNames=20=E7=9C=9F=E7=9A=84=E8=B7=9F?= =?UTF-8?q?=E4=B8=8A=E6=AC=A1=E4=B8=8D=E4=B8=80=E6=A0=B7=EF=BC=89=E6=97=B6?= =?UTF-8?q?=E6=89=8D=E5=90=8C=E6=AD=A5=E6=88=90=E5=91=98=E5=88=B0=20detail?= =?UTF-8?q?TempMembers=EF=BC=8C=E5=90=A6=E5=88=99=E4=BF=9D=E6=8C=81?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=9C=AA=E4=BF=9D=E5=AD=98=E7=9A=84=E6=88=90?= =?UTF-8?q?=E5=91=98=E7=BC=96=E8=BE=91=E4=B8=8D=E5=8F=98=EF=BC=9B=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E6=B8=85=E7=90=86=20selected=20=E4=B8=AD=E5=B7=B2?= =?UTF-8?q?=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=9A=84=E5=90=8D=E5=AD=97=20=20=20?= =?UTF-8?q?=20=20=20*=20renderDualLists=20=E4=BB=85=E5=9C=A8=20membersChan?= =?UTF-8?q?ged=20||=20stationListChanged=20||=20metaChanged=20=E6=89=8D?= =?UTF-8?q?=E8=B0=83=E7=94=A8=EF=BC=8C=E5=85=B6=E4=BD=99=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=AE=8C=E5=85=A8=E4=B8=8D=E9=87=8D=E7=BB=98=E8=AF=A6=E6=83=85?= =?UTF-8?q?=203.=20=E6=9C=8D=E5=8A=A1=E5=99=A8=20PUT=20=E7=AB=AF=E5=86=8D?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E8=BF=87=20stationNames=20=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A5=91=E7=BA=A6=E6=B2=A1=E9=97=AE=E9=A2=98=EF=BC=9A=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=20saveDetail=20=E5=8F=91=20{name,color,description,st?= =?UTF-8?q?ationNames}=20=E5=AF=B9=E5=BE=97=E4=B8=8A=20server=20PUT=20hand?= =?UTF-8?q?ler=EF=BC=8C=E4=BF=9D=E5=AD=98=E5=AE=8C=20/api/audio-cable-grou?= =?UTF-8?q?ps=20=E8=AF=BB=E5=9B=9E=20stationNames=20=E6=AD=A3=E7=A1=AE=20A?= =?UTF-8?q?PP=5FVERSION=5FTEXT=20bump=20=E5=88=B0=20v1.0.111?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CloudServer/public/cablemanager.html | 63 ++++++++++++++++++++++++---- station_broadcast.lua | 2 +- 2 files changed, 57 insertions(+), 8 deletions(-) diff --git a/CloudServer/public/cablemanager.html b/CloudServer/public/cablemanager.html index 4bfd57d..a6e2f82 100644 --- a/CloudServer/public/cablemanager.html +++ b/CloudServer/public/cablemanager.html @@ -1519,16 +1519,65 @@ async function reloadAll(options) { const silent = !!(options && options.silent); try { + const prevGroups = audioCableGroups.slice(); + const prevStations = stations.slice(); await Promise.all([loadGroups(), loadStations()]); - renderGroupList(); - renderQuickSelects(); + const groupListChanged = JSON.stringify(prevGroups.map(g => ({ id: g.id, name: g.name, color: g.color, description: g.description }))) + !== JSON.stringify(audioCableGroups.map(g => ({ id: g.id, name: g.name, color: g.color, description: g.description }))); + const stationListChanged = prevStations.length !== stations.length + || prevStations.some((s, i) => stations[i] && (s.name !== stations[i].name || s.code !== stations[i].code)); + if (groupListChanged || stationListChanged) { + renderGroupList(); + renderQuickSelects(); + } if (currentGroupId) { const g = audioCableGroups.find(g => g.id === currentGroupId); - if (g) { - detailTempMembers = [...(g.stationNames || [])]; - selectedAvailable.clear(); - selectedMembers.clear(); - renderDualLists(); + if (!g) { + currentGroupId = null; + backToList(); + } else { + const pg = prevGroups.find(x => x.id === currentGroupId) || null; + const membersChanged = !pg || JSON.stringify(pg.stationNames || []) !== JSON.stringify(g.stationNames || []); + const metaChanged = !pg || pg.name !== g.name || pg.color !== g.color || pg.description !== g.description; + + if (silent) { + // 被动自动刷新:同步名字/描述/颜色的标题区,只在后台成员真的变了才同步成员(否则保留用户未保存的编辑) + const detailNameEl = document.getElementById('detail-name'); + const detailDescEl = document.getElementById('detail-description'); + const detailTitleEl = document.getElementById('detail-title'); + if (metaChanged) { + if (detailTitleEl && detailNameEl && !detailNameEl.matches(':focus')) { + detailNameEl.value = g.name || ''; + detailTitleEl.textContent = g.name || ''; + } + if (detailDescEl && !detailDescEl.matches(':focus')) { + detailDescEl.value = g.description || ''; + } + if (detailSelectedColor !== (g.color || PRESET_COLORS[0])) { + detailSelectedColor = g.color || PRESET_COLORS[0]; + document.getElementById('detail-color').style.background = detailSelectedColor; + _rebuildDetailColorPicker(); + } + } + if (membersChanged) { + // 后台分组成员已经变了(例如被别的端删除/改了分组)—— 同步掉成员,避免用户编辑的是已经不存在的状态 + detailTempMembers = [...(g.stationNames || [])]; + // 清理选择集中已经不存在的名字,保留仍然存在的 + for (const n of Array.from(selectedAvailable)) { + if (!stations.some(s => s.name === n)) selectedAvailable.delete(n); + } + for (const n of Array.from(selectedMembers)) { + if (!detailTempMembers.includes(n)) selectedMembers.delete(n); + } + } + if (membersChanged || stationListChanged || metaChanged) renderDualLists(); + } else { + // 用户主动点刷新:全同步(包括成员) + detailTempMembers = [...(g.stationNames || [])]; + selectedAvailable.clear(); + selectedMembers.clear(); + renderDualLists(); + } } } if (!silent) showToast('成功', '数据已刷新', 'success'); diff --git a/station_broadcast.lua b/station_broadcast.lua index 2ee9164..83a1a6f 100644 --- a/station_broadcast.lua +++ b/station_broadcast.lua @@ -1,6 +1,6 @@ -- 1. Configuration & Constants -local APP_VERSION_TEXT = "v1.0.110" +local APP_VERSION_TEXT = "v1.0.111" local CONFIG = { CLOUD_URL = "ws://stabadmin.fse-media.group",