feat(ui): 文件树新增 Git 面板(提交历史 / 提交详情 / 未提交改动)
原来想看仓库改了什么只能开终端敲 git,界面里没有入口。复用预览栏做二选一 (body.pv-mode-vcs):打开时占预览的位置,点文件自动切回预览,不再各占一块屏。 三个视图只用一个渲染器:列表 → 点提交进详情,顶部「未提交的改动」进工作区, 两者仅头部信息不同(有无 commit 元信息)。只读,不做 commit / checkout / pull。 不做任何自动刷新:只在打开面板、切视图、点刷新时请求,避免边干活边被打断。 后端 git.js 用 execFile 调 git,加 -c core.quotepath=false 保中文路径不被转义成 八进制;status 用 -z 输出,否则含空格的路径带引号、和 diff 里的裸路径对不上。 patch 按单文件 120KB / 合计 400KB 截断,未跟踪文件用 diff --no-index 现算。 不是仓库或没装 git 返回 HTTP 200 + reason,由界面给空状态。 镜像补装 git,apt 源照 executor/Dockerfile 换成腾讯云镜像(默认源在国内 update 会卡死)。
This commit is contained in:
@@ -130,6 +130,7 @@ function pvOpenPane() {
|
||||
function pvCloseDoc() {
|
||||
if (!document.body.classList.contains('pv-open')) return;
|
||||
document.body.classList.remove('pv-open', 'pv-max');
|
||||
if (typeof vcsSetMode === 'function') vcsSetMode(false); // 关面板即离开 Git 模式
|
||||
if (typeof pvSetMaxUI === 'function') pvSetMaxUI(false); // 收起时复位放大钮图标(函数声明提升,定义在后亦可)
|
||||
pvClearBody();
|
||||
pvState.name = null; pvState.url = null;
|
||||
@@ -206,6 +207,7 @@ async function pvOpenOffice(name, sizeText) {
|
||||
// ---------- 统一入口:所有文件点击都走这 ----------
|
||||
async function openFilePreview(name, sizeText) {
|
||||
if (!state.sessionId) return;
|
||||
if (typeof vcsSetMode === 'function') vcsSetMode(false); // 点文件即离开 Git 面板(预览/Git 二选一)
|
||||
if (PV_OFFICE.test(name)) { try { await pvOpenOffice(name, sizeText); } catch (e) { toast('预览失败:' + e.message); } return; }
|
||||
let kind = pvKind(name);
|
||||
if (kind === 'pdf' && !navigator.pdfViewerEnabled) kind = 'none'; // WebView 内嵌不了 PDF:给占位卡,不再自动下载
|
||||
|
||||
Reference in New Issue
Block a user