From c31379c8b0abd1b4c15905f6200e189066096f52 Mon Sep 17 00:00:00 2001 From: jinghui <181050043@qq.com> Date: Mon, 26 Oct 2026 18:32:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=BF=90=E8=A1=8C=E7=9A=84=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E6=98=BE=E7=A4=BA=E5=B7=B2=E8=BF=90=E8=A1=8C=E6=97=B6?= =?UTF-8?q?=E9=95=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 7 +++++++ public/app.js | 16 +++++++++++++++- public/style.css | 2 +- server/index.js | 2 ++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a29a6b6..d347486 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # 更新日志 +## 2026-10-26 → ✨ 运行的容器显示已运行时长 + +- ✨ 容器列表每行副标题改为「项目: xxx · 已运行 1天4小时」(原来是 Docker 的英文状态 `Up 29 hours`) +- ✨ 超过 1 分钟才显示时长,刚启动显示「刚刚启动」,停止的显示「已停止」 +- 🔧 时长用紧凑格式(`1天4小时` / `38分钟`)并加宽名称列,61 行里仅 1 行仍因项目名过长省略(有 title 提示) +- 🔧 镜像名是 sha256 摘要时只显示前 12 位,避免撑爆布局 + ## 2026-10-26 → ✨ 概览新增实时流量图表(今天/昨天/30 天/12 个月/查某天) - ✨ 按小时记账:每 3 秒采样把各容器网络计数器差量累加到当天小时桶,15 秒落盘 `data/traffic/YYYY-MM-DD.json`,重启不丢 diff --git a/public/app.js b/public/app.js index 838ad9f..7f3de72 100644 --- a/public/app.js +++ b/public/app.js @@ -47,6 +47,20 @@ const fmtDur = (ms) => { if (m > 0) return `${m} 分钟`; return '不到 1 分钟'; }; +const shortImg = (img) => { + const s = String(img || ''); + if (/^sha256:/.test(s)) return s.slice(7, 19); + const last = s.split('/').pop(); + return last.length > 22 ? last.slice(0, 22) + '…' : last; +}; +const fmtDurCompact = (ms) => { + if (ms === null || ms === undefined || !isFinite(ms) || ms < 0) return '—'; + const s = Math.floor(ms / 1000), d = Math.floor(s / 86400), h = Math.floor((s % 86400) / 3600), m = Math.floor((s % 3600) / 60); + if (d > 0) return `${d}天${h ? h + '小时' : ''}`; + if (h > 0) return `${h}小时${m ? m + '分' : ''}`; + if (m > 0) return `${m}分钟`; + return '1分钟内'; +}; const ago = (iso) => { if (!iso) return '-'; const d = (Date.now() - new Date(iso).getTime()) / 1000; @@ -508,7 +522,7 @@ async function renderContainers(silent, mode = 'running') { return `