From 8ef4ec1ee4fa9e929b72bcfe03e3f67c6d24be5f Mon Sep 17 00:00:00 2001 From: kicer Date: Wed, 11 Nov 2026 15:03:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(local):=20=E6=96=87=E4=BB=B6=E6=A0=91?= =?UTF-8?q?=E6=8F=90=E5=8D=87=E4=B8=BA=E6=A1=8C=E9=9D=A2=E7=AB=AF=E9=80=9A?= =?UTF-8?q?=E7=94=A8=E5=85=A5=E5=8F=A3=EF=BC=8C=E6=8E=A5=E7=AE=A1=E6=97=A7?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E9=9D=A2=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 桌面端(含服务器形态)用左栏懒加载文件树取代输入行右侧的旧「任务文件」浮层: 点文件进右侧预览,行内可下载 / 删除;local 形态额外提供「在 Finder 中显示」。 - routes/files.js:新增 GET /:id/tree(单层懒加载、忽略大目录、上限 500、 字面 + realpath 双重越界校验),替代会同步递归整棵目录的 GET /:id/files - routes/local.js:移除 /tree(上收为通用接口),只留 pick-dir / reveal / terminal - local-files.js → files-tree.js:两种形态共用;local 能力靠 /api/local/info 探测, 服务器形态自动隐藏 Finder/终端入口 - 树头部复用预览栏的 .pv-head / .pv-addr / .pv-actions / .icon-btn: 左右并排时高度、图标尺寸与描边完全一致 - 树头不再显示会话标题(原样搬过来容易和会话列表重复),改为显示工作目录路径 - 桌面端隐藏 #files-btn;手机端保留旧面板 - 上传完成后同步刷新文件树 --- app/server/public/css/style.css | 33 ++-- app/server/public/index.html | 8 +- app/server/public/js/files-tree.js | 287 ++++++++++++++++++++++++++++ app/server/public/js/files.js | 2 + app/server/public/js/local-files.js | 238 ----------------------- app/server/routes/files.js | 66 +++++++ app/server/routes/local.js | 50 +---- docs/local-mode.md | 12 +- 8 files changed, 384 insertions(+), 312 deletions(-) create mode 100644 app/server/public/js/files-tree.js delete mode 100644 app/server/public/js/local-files.js diff --git a/app/server/public/css/style.css b/app/server/public/css/style.css index eb72169..15f5f30 100644 --- a/app/server/public/css/style.css +++ b/app/server/public/css/style.css @@ -872,30 +872,23 @@ body.voice-active .scroll-bottom-btn { display: none; } width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; } -/* 手机/窄屏没有右侧预览栏(预览走全屏浮层),这个按钮无意义 */ -@media (max-width: 959px) { #da-preview { display: none !important; } } +/* 手机/窄屏没有右侧预览栏(预览走全屏浮层),也没有左栏文件树(窄屏不适合) */ +@media (max-width: 959px) { #da-preview, #da-files { display: none !important; } } .files-tree { display: none; flex: 1; min-height: 0; flex-direction: column; } #drawer.drawer-mode-files .drawer-search, #drawer.drawer-mode-files .drawer-list { display: none; } #drawer.drawer-mode-files .files-tree { display: flex; } -.tree-head { - flex: none; display: flex; align-items: center; gap: 4px; - padding: 8px 12px 6px; border-bottom: 1px solid var(--border); +/* 左栏树头部复用预览栏的 .pv-head/.pv-addr/.pv-actions/.icon-btn: + 它俩在桌面上左右并排,高一点点或图标小一号都会明显错位。 */ +.tree-head .pv-actions { gap: 4px; margin-left: 6px; } /* 侧栏窄,4 个按钮也塞得下 */ +.tree-path { + overflow: hidden; text-overflow: ellipsis; white-space: nowrap; + cursor: default; } -.tree-title { - flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; - font-size: 13px; color: var(--ink); -} -.tree-actions { display: flex; gap: 2px; } -.tree-hbtn { - width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; - border: 0; background: none; border-radius: 8px; color: var(--gray); cursor: pointer; -} -.tree-hbtn:hover { background: var(--surface); color: var(--active); } -.tree-hbtn.active { color: var(--active); background: var(--active-soft); } -.tree-hbtn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; } +/* 头部图标的「开启中」态(如显示隐藏文件) */ +.pv-actions .icon-btn.active { color: var(--active); background: var(--active-soft); } .tree-body { flex: 1; min-height: 0; overflow: auto; padding: 4px 6px 12px; } .tree-row { @@ -924,11 +917,13 @@ body.voice-active .scroll-bottom-btn { display: none; } } .tree-row:hover .tree-act { display: inline-flex; } .tree-act:hover { background: var(--border); color: var(--active); } +.tree-act.danger:hover { background: #fdf3f2; color: #c0392b; } .tree-act svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; } .tree-empty, .tree-loading, .tree-more { padding: 10px 12px; font-size: 12px; color: var(--gray); } -/* 本地模式:隐藏旧的底部「任务文件」浮层入口(它走整棵递归接口,大项目会卡死。改用左栏树) */ -body.local-mode #files-btn { display: none !important; } +/* 桌面端:文件浏览交给左栏文件树,隐藏输入行右侧的旧「任务文件」浮层入口。 + 手机端仍用它(窄屏放不下树)。 */ +@media (min-width: 960px) { #files-btn { display: none !important; } } /* 会话分组表头(按今天/昨天分组):滚动时吸顶,下一个 group-label 滚过来时把它顶走 背景色与抽屉一致,避免 sticky 时下面会话透过看到上一组的尾巴 */ .group-label { diff --git a/app/server/public/index.html b/app/server/public/index.html index cfa2791..5eada14 100644 --- a/app/server/public/index.html +++ b/app/server/public/index.html @@ -234,13 +234,13 @@
- - +
+
-