diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fc75be..5f53b7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # 更新日志 +## 2026-10-26 → 🔧 概览页改为纯仪表盘,不再铺全部应用 + +- 🔧 概览页只保留:统计条、CPU/内存 Top 5、优化建议、**需要关注的应用**(仅异常/注意,最多 6 个)、最近事件 +- ✨ 新增「查看全部应用 50 个 →」进入独立的**全部应用**视图(筛选/排序/全部卡片都在这里),顶部有「← 返回概览」 +- 🔧 全部应用视图下左侧「概览」保持高亮,标题显示「全部应用」 +- 🔧 无异常时概览显示「所有应用运行正常,无需处理」绿色提示 + ## 2026-10-26 → ✨ 概览页新增 CPU / 内存占用 Top 5 - ✨ 概览页统计条下方新增两个榜单:**CPU 占用 Top 5**(占整机 %,标注核数)、**内存占用 Top 5**(绝对值 + 占整机比例) diff --git a/README.md b/README.md index d009ce2..65446a0 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,8 @@ bash install.sh | 页面 | 内容 | |---|---| -| 应用(默认) | 健康看板:应用总数/异常/注意/资源/运行容器;筛选(全部·有问题·已停止·高占用);应用卡片(状态胶囊、CPU 占整机、内存、网络、端口、**已运行时长**、可用率、重启次数、问题摘要);卡片内直接启停重启;底部最近事件时间线。**排序默认「异常优先」**,其次按资源占用 | +| 概览(默认) | 纯仪表盘:应用总数/异常/注意/资源/运行容器统计条、**CPU 与内存占用 Top 5**、优化建议、**需要关注的应用**(仅异常/注意,最多 6 个,卡片可直接启停)、最近事件;右上「查看全部应用」进入完整列表 | +| 全部应用 | 完整应用卡片列表(50 个):筛选(全部·有问题·已停止·高占用)、排序、状态胶囊、CPU/内存/网络、端口、已运行时长、可用率、重启次数、卡片内启停与详情;顶部可返回概览 | | 应用详情 | 应用级指标 + 全部容器表格(状态/健康/CPU/内存/网络/重启/运行时长/单容器操作)+ 三个标签页:容器、聚合日志(多容器合并、按容器名加前缀)、事件;顶部可整应用启停重启 | | 容器 | 只列运行中容器,可排序(CPU/内存/网络/磁盘IO/进程数/名称)、搜索;行内启停/重启/删除/详情/打开端口 | | 停止的容器 | 两个部分:**有镜像但未启动的应用**(compose 项目存在、本地有镜像、但一个容器都没有,可一键 `docker compose up -d`)+ 已停止/退出的容器(只保留启动/删除/详情) | diff --git a/public/app.js b/public/app.js index a47a730..a4b6d19 100644 --- a/public/app.js +++ b/public/app.js @@ -70,7 +70,7 @@ function toast(msg, err) { } /* ---------------- 路由 ---------------- */ -const TITLES = { apps: '概览', containers: '运行的容器', stopped: '停止的容器', images: '本地镜像', registry: '镜像仓库', networks: '网络', settings: '告警设置' }; +const TITLES = { apps: '概览', 'apps-all': '全部应用', containers: '运行的容器', stopped: '停止的容器', images: '本地镜像', registry: '镜像仓库', networks: '网络', settings: '告警设置' }; const SORTS = { apps: [['severity', '异常优先'], ['cpu', 'CPU 占用'], ['mem', '内存占用'], ['containers', '容器数'], ['name', '名称']], containers: [['cpu', 'CPU 占用'], ['mem', '内存占用'], ['net', '网络速率'], ['io', '磁盘 IO'], ['pids', '进程数'], ['name', '名称']], @@ -79,12 +79,13 @@ const SORTS = { function go(view) { state.view = view; state.currentApp = null; - $$('#nav a').forEach(a => a.classList.toggle('active', a.dataset.view === view)); + const navView = view === 'apps-all' ? 'apps' : view; + $$('#nav a').forEach(a => a.classList.toggle('active', a.dataset.view === navView)); $('#pageTitle').textContent = TITLES[view] || view; - const isList = ['apps', 'containers', 'stopped'].includes(view); + const isList = ['apps', 'apps-all', 'containers', 'stopped'].includes(view); $('#search').style.display = isList || view === 'images' ? '' : 'none'; $('#sortbox').style.display = isList ? '' : 'none'; - const opts = SORTS[view] || SORTS.containers; + const opts = SORTS[view] || SORTS[navView] || SORTS.containers; if (state.sort && !opts.some(o => o[0] === state.sort)) state.sort = opts[0][0]; $('#sort').innerHTML = opts.map(([v, t]) => ``).join(''); $('#sort').value = state.sort; @@ -103,7 +104,7 @@ async function render(silent) { if (state.appTab === 'containers' && state.currentApp) return openApp(state.currentApp); return; } - if (state.view === 'apps') return renderApps(silent); + if (state.view === 'apps' || state.view === 'apps-all') return renderApps(silent); if (state.view === 'containers') return renderContainers(silent, 'running'); if (state.view === 'stopped') return renderContainers(silent, 'stopped'); if (state.view === 'images') return renderImages(); @@ -158,7 +159,7 @@ async function renderApps(silent) { const pill = (a) => `${a.statusText}`; const chips = [['all', '全部', s.total], ['issues', '有问题', s.critical + s.warning], ['stopped', '已停止', s.stopped], ['high', '高占用', '']]; - const cards = data.items.map(a => ` + const cardOf = (a) => `
${avatar(a.name)} @@ -184,7 +185,8 @@ async function renderApps(silent) {
-
`).join(''); + `; + const cards = data.items.map(cardOf).join(''); const allApps = (full && full.items) || data.items || []; const topCpu = [...allApps].sort((x, y) => (y.cpuPctOfMachine || 0) - (x.cpuPctOfMachine || 0)).slice(0, 5); @@ -244,7 +246,22 @@ async function renderApps(silent) { `; - $('#view').innerHTML = ` + const isAll = state.view === 'apps-all'; + const attn = allApps.filter(a => a.severity > 0).slice(0, 6); + const totalApps = s.total; + + if (isAll) { + $('#view').innerHTML = ` +
全部应用共 ${totalApps} 个 · 点击卡片查看详情 +
+
+ ${chips.map(([k, t2, n]) => ``).join('')} + 按状态异常优先、其次资源占用排序 +
+
${cards || '
没有匹配的应用
'}
`; + $('#backOverview').onclick = () => go('apps'); + } else { + $('#view').innerHTML = `
应用总数
${s.total}
${s.containers} 个容器
异常
${s.critical}
需要立即处理
@@ -256,17 +273,16 @@ async function renderApps(silent) { ${topHtml} ${insHtml} -
- ${chips.map(([k, t, n]) => ``).join('')} - 按状态异常优先、其次资源占用排序 -
- -
${cards || '
没有匹配的应用
'}
+
需要关注的应用${attn.length ? `${attn.length} 个异常或需要注意` : '全部正常'} +
+ ${attn.length ? `
${attn.map(cardOf).join('')}
` : '
所有应用运行正常,无需处理
'}

最近事件

状态变化与重启记录
${ev.items.length ? ev.items.map(e => `
${timeStr(e.t)}
${esc(e.title)}
${esc(e.detail || '')}
`).join('') : '
暂无事件
'}
`; + $('#openAllApps').onclick = () => go('apps-all'); + } $$('#view .chip').forEach(b => b.onclick = () => { state.filter = b.dataset.filter; render(); }); $$('#view .top-row').forEach(r => r.onclick = () => openApp(r.dataset.top)); diff --git a/public/style.css b/public/style.css index ba462c8..1f51f00 100644 --- a/public/style.css +++ b/public/style.css @@ -287,3 +287,4 @@ table.tb th.num{text-align:right} .tbar i{display:block;height:100%;border-radius:3px;background:#1a73e8} .tbar.mem i{background:#7a5af8} .empty.sm{padding:16px;font-size:12px;text-align:center;color:#8b95a5} +.empty.ok-empty{padding:22px;text-align:center;color:#12a15f;background:#f3fbf6;border:1px dashed #cdebd9;border-radius:12px;font-size:13px}