perf(文件面板): 改成按目录懒加载,不再一次拉全量文件树
底部「任务文件」浮层原来是 GET /:id/files 全量递归:仓库级工作目录能扫出 10544 个文件、1.4MB(其中 81% 在 node_modules),移动端经隧道打开要好几秒。 改成和侧边栏同一个 /tree 接口,只拉当前这一层(单层 readdirSync,上限 500 条)。 根目录 1.4MB/144ms → 1.3KB/3.5ms,进任意子目录也是毫秒级。node_modules 这类 大目录由 TREE_IGNORE_DIRS 灰显沉底,但可以点进去,进哪层拉哪层。 配套: - 目录行右侧显示修改时间(原来算递归文件数,懒加载拿不到) - 新增 fmtFileTime,文件和目录统一成「年/月/日 时:分」(全局 fmtTime 对今天只给时分) - /tree 给文件条目补 mtimeMs(原来只给目录,文件时间显示不出来) - showFileTree 缓存还在就复用,反复开关面板不再重拉已展开的层 - refreshFileTree 提到 sessionId 变更处,切会话不再先闪一下上个会话的文件
This commit is contained in:
@@ -124,9 +124,9 @@ router.get('/:id/tree', function (req, res) {
|
||||
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 (_) {}
|
||||
entries.push({ name: e.name, rel: childRel, type: 'file', size: size });
|
||||
let size = null, mtimeMs = null;
|
||||
try { const st = fs.statSync(path.join(abs, e.name)); size = st.size; mtimeMs = st.mtimeMs; } catch (_) {}
|
||||
entries.push({ name: e.name, rel: childRel, type: 'file', size: size, mtimeMs: mtimeMs });
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user