From 98478f5ebc751943893d2707e084f08656f20b03 Mon Sep 17 00:00:00 2001
From: jinghui <181050043@qq.com>
Date: Mon, 26 Oct 2026 17:59:22 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9C=8D=E5=8A=A1=E7=AB=AF=E6=9B=B4?=
=?UTF-8?q?=E6=96=B0=E5=90=8E=E9=A1=B5=E9=9D=A2=E8=87=AA=E5=8A=A8=E5=88=B7?=
=?UTF-8?q?=E6=96=B0=EF=BC=8C=E9=81=BF=E5=85=8D=E6=94=B9=E4=BA=86=E7=9C=8B?=
=?UTF-8?q?=E4=B8=8D=E5=88=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CHANGELOG.md | 7 +++++++
public/app.js | 6 ++++++
public/index.html | 2 +-
server/index.js | 4 +++-
4 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dbb475e..90ff1e3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,12 @@
# 更新日志
+## 2026-10-26 → ✨ 服务端更新后页面自动刷新(解决"改了看不到")
+
+- ✨ `/api/host` 返回 `build`(每次进程启动生成),前端发现 build 变化自动 `location.reload()`
+- 🔧 已开着的老页面会在下一次 3 秒轮询时自动切到新版本,不需要手动 Ctrl+F5
+- 🔧 菜单「运行的容器」文案加了 `#navContainersLabel` 并在刷新时兜底校正
+- ✅ 实测:页面开着 → `docker restart` 服务 → 6 秒内页面自刷、标记丢失、build 更新、菜单为新文案
+
## 2026-10-26 → 🔧 「应用」菜单改名「概览」并作为默认页
- 🔧 左侧菜单「应用」→「**概览**」,页面标题同步
diff --git a/public/app.js b/public/app.js
index 3513ddf..5d13b13 100644
--- a/public/app.js
+++ b/public/app.js
@@ -3,6 +3,7 @@
/* ---------------- 基础 ---------------- */
const $ = (s, r = document) => r.querySelector(s);
const $$ = (s, r = document) => [...r.querySelectorAll(s)];
+let serverBuild = null;
const state = { view: 'apps', filter: 'all', sort: 'severity', order: 'desc', q: '', timer: null, current: null, currentApp: null, tab: 'stat', appTab: 'containers', insightOpen: false };
const REFRESH_KEY = 'dc.refreshMs';
state.refreshMs = Math.min(30000, Math.max(1000, Number(localStorage.getItem(REFRESH_KEY)) || 3000));
@@ -115,6 +116,11 @@ async function render(silent) {
/* ---------------- 主机信息 ---------------- */
async function refreshHost() {
const h = await api('/api/host');
+ if (h.build) {
+ if (serverBuild && serverBuild !== h.build) { location.reload(); return h; }
+ serverBuild = h.build;
+ }
+ const navCl = $('#navContainersLabel'); if (navCl && navCl.textContent !== '运行的容器') navCl.textContent = '运行的容器';
$('#hostMini').innerHTML = `${esc(h.hostname)}
${h.cpus} 核 · 内存 ${fmtBytes(h.memTotal)}
运行 ${h.running} / 共 ${h.containers} 容器`;
$('#navRunning').textContent = h.running;
$('#navStopped').textContent = (h.stopped || 0) + (h.pending || 0);
diff --git a/public/index.html b/public/index.html
index 83de510..61d41bc 100644
--- a/public/index.html
+++ b/public/index.html
@@ -17,7 +17,7 @@