fix(ui): 空目录不再显示「(空目录)」,mtime 没变就不再请求

点开空文件夹只多一行「(空目录)」,本来就没有展开箭头(.tree-row.open 没有任何样式),
这行提示是唯一的视觉变化,去掉后点击就是看不出变化。根目录的空提示保留:整个文件树
空白时分不清是空还是没加载。

顺带省掉自动刷新时对空目录的重复请求:tree 接口给目录 entry 补 mtimeMs(readdir 的
Dirent 不带时间,statSync 一次即可),前端把确认空的目录记成 rel -> mtimeMs。目录内
增删子项会更新目录自身 mtime,父目录重拉时比对不上就重新请求——所以 AI 往空目录里写了
文件依然会自动出现,不会因为缓存看不见。invalidate(true) 保留这份记录,切会话/新建/
切隐藏文件(invalidate(false))清空。
This commit is contained in:
2026-11-13 15:57:49 +08:00
parent 95047678f3
commit 8694061068
2 changed files with 22 additions and 8 deletions
+4 -1
View File
@@ -119,7 +119,10 @@ router.get('/:id/tree', function (req, res) {
const childRel = rel ? rel + '/' + e.name : e.name;
if (e.isSymbolicLink()) { entries.push({ name: e.name, rel: childRel, type: 'link' }); continue; }
if (e.isDirectory()) {
entries.push({ name: e.name, rel: childRel, type: 'dir', ignored: TREE_IGNORE_DIRS.has(e.name) });
// 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 });
} else if (e.isFile()) {
let size = null;
try { size = fs.statSync(path.join(abs, e.name)).size; } catch (_) {}