From b57fef13d4414d3fd562bcc55b46879b523eedc0 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Sun, 2 Aug 2026 14:10:08 +0800 Subject: [PATCH] =?UTF-8?q?refactor(control):=20=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E7=9B=91=E6=8E=A7=E9=A1=B5=E6=95=B0=E6=8D=AE=E4=B8=8E=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E7=9C=8B=E6=9D=BF=E7=BB=9F=E4=B8=80(=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF=E6=B8=B2=E6=9F=93)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题: monitor 页前端 fetch /api/monitor/channels 拿残缺数据 (仅通道名),再打补丁关联视频源名——数据源不统一。 修复: 提取 consolePageData() 共用,monitor 页服务端渲染 ConsoleDevices.Channels(含 SourceName/Display),显示 '设备名 · 视频源名',与看板完全同源。 撤销 channelMetaMap 补丁(不再需要);monitor JS 直接用 data-channel 构造 HLS URL。 --- control/internal/web/ui.go | 14 +- .../internal/web/ui/templates/monitor.html | 193 ++++++++---------- 2 files changed, 92 insertions(+), 115 deletions(-) diff --git a/control/internal/web/ui.go b/control/internal/web/ui.go index 4946bf2..9ded025 100644 --- a/control/internal/web/ui.go +++ b/control/internal/web/ui.go @@ -1075,10 +1075,9 @@ func (u *UI) pageDashboard(w http.ResponseWriter, r *http.Request) { u.render(w, r, "dashboard", data) } -func (u *UI) pageConsole(w http.ResponseWriter, r *http.Request) { +func (u *UI) consolePageData() PageData { u.ensureDevicesLoaded() data := PageData{Title: "运行看板"} - data.Message = strings.TrimSpace(r.URL.Query().Get("msg")) devices := u.registry.GetDevices() data.Devices = devices @@ -1316,6 +1315,12 @@ func (u *UI) pageConsole(w http.ResponseWriter, r *http.Request) { data.ConsoleVideoSources = unassigned data.ConsoleAllVideoSources = allSources + return data +} + +func (u *UI) pageConsole(w http.ResponseWriter, r *http.Request) { + data := u.consolePageData() + data.Message = strings.TrimSpace(r.URL.Query().Get("msg")) u.render(w, r, "console", data) } @@ -5957,8 +5962,9 @@ func (u *UI) actionDeviceFaceGalleryReload(w http.ResponseWriter, r *http.Reques } func (u *UI) pageMonitor(w http.ResponseWriter, r *http.Request) { - u.ensureDevicesLoaded() - u.render(w, r, "monitor", PageData{Title: "视频监控", Devices: u.registry.GetDevices()}) + data := u.consolePageData() + data.Title = "视频监控" + u.render(w, r, "monitor", data) } func (u *UI) apiMonitorChannels(w http.ResponseWriter, r *http.Request) { diff --git a/control/internal/web/ui/templates/monitor.html b/control/internal/web/ui/templates/monitor.html index 647372c..18c9a0a 100644 --- a/control/internal/web/ui/templates/monitor.html +++ b/control/internal/web/ui/templates/monitor.html @@ -6,134 +6,105 @@
所有在线设备的实时画面
- +
-
加载中…
+ {{$hasCard := false}} + {{range $cd := .ConsoleDevices}}{{if $cd.Device.Online}}{{range $ch := $cd.Channels}} + {{$hasCard = true}} +
+
+ {{$cd.Device.DisplayName}} · {{if $ch.SourceName}}{{$ch.SourceName}}{{else}}{{$ch.Display}}{{end}} +
+ +
+ {{end}}{{end}}{{end}} + {{if not $hasCard}} +
暂无在线设备的视频通道
+ {{end}}
{{end}}