refactor(文件面板): 去掉目录名黑名单,out/dist 等不再灰显

当初列 node_modules/.git/dist/build/out 等名字,是因为文件树一次性拉全量
(1.4MB)怕撑爆;现在已改成按目录懒加载、单层最多 500 条,这个限制没意义了,
反而误伤项目自己的 out/(两个文件也点不开)。

- 后端 /tree 不再返回 ignored 字段,排序回到「目录在前、文件在后」
- 前端去掉 is-ignored 的样式、勾选框排除与点击拦截
- CSS 删掉 .tree-row.is-ignored
This commit is contained in:
2026-11-17 16:45:35 +08:00
parent 3139108838
commit e928fd7cb0
3 changed files with 7 additions and 18 deletions
-1
View File
@@ -1159,7 +1159,6 @@ body.voice-active .scroll-bottom-btn { display: none; }
font-size: 13px; color: var(--ink); white-space: nowrap;
}
.tree-row:hover { background: var(--surface); }
.tree-row.is-ignored { color: var(--gray-light); cursor: default; }
.tree-row.is-link { color: var(--gray); }
.tree-ico { flex: none; width: 16px; height: 16px; display: inline-flex; color: var(--gray); }
.tree-ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
+5 -10
View File
@@ -98,13 +98,12 @@
if (expanded.has(ent.rel)) row.classList.add('open');
}
if (ent.type === 'link') row.classList.add('is-link');
if (ent.ignored) row.classList.add('is-ignored');
// 不画展开箭头:文件夹图标已经说明可以点,点行任意位置都能展开/收起。
// 勾选框:hover 或已选中时淡入,但占位始终在,避免 hover 时文件名左右跳。
// 忽略的大目录和软链不参与批量操作(后端也不让删),所以不给勾选框。
if (!ent.ignored && ent.type !== 'link') {
// 软链不参与批量操作(后端也不让删),所以不给勾选框。
if (ent.type !== 'link') {
const chk = document.createElement('span');
chk.className = 'tree-check';
chk.setAttribute('role', 'checkbox');
@@ -125,10 +124,6 @@
name.textContent = ent.name;
row.appendChild(name);
if (ent.ignored) {
row.title = ent.rel + '(已忽略的大目录/构建产物)';
return row;
}
// 行内动作:服务器形态给「下载 / 删除」;local 本就跑在同一台机器上,
// 「下载」到本地是多余的(用 Finder 直接看原文件更顺),所以换成「在 Finder 中显示」。
// @ 引用排最前:它是「往输入框送东西」的动作,和后面的下载 / Finder / 删除(对文件本身动手)分开
@@ -149,7 +144,7 @@
if (!list.length && !rel) tip(frag, '(空目录)');
for (const ent of list) {
frag.appendChild(rowFor(ent, depth));
if (ent.type === 'dir' && !ent.ignored && expanded.has(ent.rel)) {
if (ent.type === 'dir' && expanded.has(ent.rel)) {
const kids = document.createElement('div');
kids.className = 'tree-children';
frag.appendChild(kids);
@@ -246,7 +241,7 @@
const body = $('tree-body');
if (!body) return [];
return Array.from(body.querySelectorAll('.tree-row')).filter(function (r) {
return !r.classList.contains('is-ignored') && r.dataset.type !== 'link';
return r.dataset.type !== 'link';
});
}
@@ -386,7 +381,7 @@
else if (a === 'at') insertPathRef(rel, isDir);
return;
}
if (row.classList.contains('is-ignored') || row.dataset.type === 'link') return;
if (row.dataset.type === 'link') return;
if (isDir) {
if (expanded.has(rel)) expanded.delete(rel); else expanded.add(rel);
renderBody();
+2 -7
View File
@@ -81,10 +81,6 @@ router.post('/:id/files', upload.array('files', 10), function (req, res) {
// 为什么不复用 GET /:id/files:那个接口同步递归整棵目录,会话里一旦有大项目 /
// node_modules,单线程 core 会被卡死(连 SSE 一起挂)。这里一律「一次一层」、
// 忽略大目录、限量返回,客户端展开才请求下一层。
const TREE_IGNORE_DIRS = new Set([
'node_modules', '.git', 'dist', 'build', 'out', 'target', '.venv', 'venv',
'__pycache__', '.next', '.cache', 'coverage', '.idea', '.vscode',
]);
const TREE_MAX = 500;
// 相对路径 → 会话根内的绝对路径。字面 + realpath 双重校验,防符号链接跳出会话目录。
@@ -122,7 +118,7 @@ router.get('/:id/tree', function (req, res) {
// mtimeMs 给前端判断空目录是否还是空的:目录内增删子项会更新它
let mtimeMs = null;
try { mtimeMs = fs.statSync(path.join(abs, e.name)).mtimeMs; } catch (_) {}
entries.push({ name: e.name, rel: childRel, type: 'dir', ignored: TREE_IGNORE_DIRS.has(e.name), mtimeMs: mtimeMs });
entries.push({ name: e.name, rel: childRel, type: 'dir', mtimeMs: mtimeMs });
} else if (e.isFile()) {
let size = null, mtimeMs = null;
try { const st = fs.statSync(path.join(abs, e.name)); size = st.size; mtimeMs = st.mtimeMs; } catch (_) {}
@@ -132,9 +128,8 @@ router.get('/:id/tree', function (req, res) {
} catch (err) {
return res.status(500).json({ error: String((err && err.message) || err) });
}
// 排序:正常目录 → 正常文件 → 被忽略的大目录(灰显沉底);同类按名称
// 排序:目录在前、文件在后;同类按名称
entries.sort((a, b) =>
(a.ignored ? 1 : 0) - (b.ignored ? 1 : 0) ||
(a.type === 'dir' ? 0 : 1) - (b.type === 'dir' ? 0 : 1) ||
(a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
res.json({