From 573faf4139adb4488a8f22dc216f2812e41c6135 Mon Sep 17 00:00:00 2001 From: jinghui <181050043@qq.com> Date: Mon, 26 Oct 2026 23:01:23 +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=E9=BB=98=E8=AE=A4=E6=8C=89=E6=9C=80=E6=96=B0=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E6=8E=92=E5=BA=8F=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E9=A1=B9=E4=B8=8E=E5=AE=89=E8=A3=85=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 7 +++++++ README.md | 2 +- public/app.js | 23 ++++++++++++++++------- server/index.js | 3 ++- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a0dd59..0ba93a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # 更新日志 +## 2026-10-26 → ✨ 运行的容器默认按「最新安装」排序 + +- ✨ 排序新增「最新安装」(按容器创建时间降序),并设为「运行的容器」页默认排序;接口 `sort` 缺省也改为 `created` +- ✨ 排序选择**按页面记忆**(`localStorage['dc.sortBy']`),切到别的页再回来仍是你上次选的 +- ✨ 安装时间可见性:行 hover 提示加「安装于 2026/10/26 22:59」,容器详情抽屉新增「安装时间」一行(副标题不加,避免被截断) +- ✅ 实测:默认排序为「最新安装」,前 5 行与 `docker ps` 创建时间完全一致(22:54 docker-center → 17:17 unicut → 14:38 katelyatv);61 行副标题仅 1 行因项目名过长省略(有 tooltip) + ## 2026-10-26 → 🔧 侧栏去掉「停止的容器」入口 - 🔧 侧栏菜单精简为:概览 / 运行的容器 / 本地镜像 / 镜像仓库 / 网络 / 备份与恢复 / 告警设置 diff --git a/README.md b/README.md index 5cc3096..204cb66 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Docker 自带面板和 Portainer 都是按「容器」管理:六十多个容 - 应用详情:全部容器表格 + 聚合日志(多容器合并)+ 事件,支持整应用启停 **容器与项目** -- 运行的容器:只列运行中,可按 CPU/内存/网络/磁盘IO/进程数/名称排序,显示已运行时长 +- 运行的容器:只列运行中,默认按**最新安装**排序,也可按 CPU/内存/网络/磁盘IO/进程数/名称排序,显示已运行时长 - 本地镜像(可清理悬空镜像)、镜像仓库拉取、网络 **备份与恢复** diff --git a/public/app.js b/public/app.js index b3cd64f..4f6452d 100644 --- a/public/app.js +++ b/public/app.js @@ -6,6 +6,8 @@ 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, traffic: { range: 'today', date: '' }, sel: new Set(), imgSel: new Set(), pendSel: new Set() }; const REFRESH_KEY = 'dc.refreshMs'; +const SORT_KEY = 'dc.sortBy'; +try { state.sortBy = JSON.parse(localStorage.getItem(SORT_KEY) || '{}') || {}; } catch (e) { state.sortBy = {}; } state.refreshMs = Math.min(30000, Math.max(1000, Number(localStorage.getItem(REFRESH_KEY)) || 3000)); const PAUSE_KEY = 'dc.paused'; state.paused = localStorage.getItem(PAUSE_KEY) === '1'; @@ -128,8 +130,8 @@ function toast(msg, err) { const TITLES = { apps: '概览', 'apps-all': '全部应用', containers: '运行的容器', stopped: '停止的容器', images: '本地镜像', registry: '镜像仓库', networks: '网络', backup: '备份与恢复', settings: '告警设置' }; const SORTS = { apps: [['severity', '异常优先'], ['cpu', 'CPU 占用'], ['mem', '内存占用'], ['containers', '容器数'], ['name', '名称']], - containers: [['cpu', 'CPU 占用'], ['mem', '内存占用'], ['net', '网络速率'], ['io', '磁盘 IO'], ['pids', '进程数'], ['name', '名称']], - stopped: [['name', '名称'], ['mem', '内存占用']], + containers: [['created', '最新安装'], ['cpu', 'CPU 占用'], ['mem', '内存占用'], ['net', '网络速率'], ['io', '磁盘 IO'], ['pids', '进程数'], ['name', '名称']], + stopped: [['created', '最新安装'], ['name', '名称'], ['mem', '内存占用']], }; function go(view) { if (state.view !== view && state.sel) state.sel.clear(); @@ -142,7 +144,8 @@ function go(view) { $('#search').style.display = isList || view === 'images' ? '' : 'none'; $('#sortbox').style.display = isList ? '' : 'none'; const opts = SORTS[view] || SORTS[navView] || SORTS.containers; - if (state.sort && !opts.some(o => o[0] === state.sort)) state.sort = opts[0][0]; + const saved = state.sortBy[view] || state.sortBy[navView]; + state.sort = (saved && opts.some(o => o[0] === saved)) ? saved : opts[0][0]; $('#sort').innerHTML = opts.map(([v, t]) => ``).join(''); $('#sort').value = state.sort; $('#addBtn').textContent = view === 'registry' ? '拉取镜像' : view === 'images' ? '清理悬空镜像' : '添加容器'; @@ -657,8 +660,8 @@ async function renderContainers(silent, mode = 'running') { return `