From 3376974d0f56c27296c44b08befb984e5c832025 Mon Sep 17 00:00:00 2001 From: xintaofei Date: Fri, 13 Mar 2026 21:50:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=96=87=E4=BB=B6=E5=92=8C?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E5=8C=BA=E5=9F=9F=E7=9A=84=E6=A0=B9=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E5=BF=AB=E6=8D=B7=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/files/file-workspace-panel.tsx | 2 +- .../layout/aux-panel-file-tree-tab.tsx | 175 ++++++++++++++---- .../layout/aux-panel-git-changes-tab.tsx | 126 +++++++++++-- src/contexts/workspace-context.tsx | 8 +- 4 files changed, 252 insertions(+), 59 deletions(-) diff --git a/src/components/files/file-workspace-panel.tsx b/src/components/files/file-workspace-panel.tsx index 5e40d8a..7f3b17b 100644 --- a/src/components/files/file-workspace-panel.tsx +++ b/src/components/files/file-workspace-panel.tsx @@ -1120,7 +1120,7 @@ export function FileWorkspacePanel() { path: diffListContext.path, branch: diffListContext.branch, }) - : diffListContext.path + : (activeFileTab.description ?? diffListContext.path) const handleOpenDiff = async (path: string) => { if (diffListContext.kind === "commit") { diff --git a/src/components/layout/aux-panel-file-tree-tab.tsx b/src/components/layout/aux-panel-file-tree-tab.tsx index 4df8655..0014742 100644 --- a/src/components/layout/aux-panel-file-tree-tab.tsx +++ b/src/components/layout/aux-panel-file-tree-tab.tsx @@ -1701,6 +1701,22 @@ export function FileTreeTab() { return baseName(folder.path) }, [folder?.path, t]) + const systemExplorerLabel = + typeof navigator === "undefined" + ? t("openInFileManager") + : (() => { + const platform = + `${navigator.platform} ${navigator.userAgent}`.toLowerCase() + if (platform.includes("mac")) return t("openInFinder") + if (platform.includes("win")) return t("openInExplorer") + return t("openInFileManager") + })() + + const rootTarget: FileActionTarget = useMemo( + () => ({ kind: "dir", path: "", name: rootNodeName }), + [rootNodeName] + ) + useEffect(() => { if (!isFileTreeTabActive) return void fetchTree() @@ -2009,45 +2025,128 @@ export function FileTreeTab() { onSelect={handleTreeSelect} > {folder?.path && ( - - {nodes.map((node) => ( - { - void openFilePreview(path) + + + + {nodes.map((node) => ( + { + void openFilePreview(path) + }} + onOpenFileDiff={(path) => { + void openWorkingTreeDiff(path) + }} + onOpenDirDiff={(path) => { + void openWorkingTreeDiff(path, { + mode: "overview", + }) + }} + onOpenCommitWindow={handleOpenCommitWindow} + onRequestCompareWithBranch={ + handleRequestCompareWithBranch + } + onRequestRollback={handleRequestRollback} + onOpenDirInTerminal={handleOpenDirInTerminal} + onRequestAddToVcs={handleAddToVcs} + onRequestRename={handleRequestRename} + onRequestDelete={handleRequestDelete} + onRefresh={fetchTree} + /> + ))} + + + + + + {t("git")} + + + handleOpenCommitWindow()} + disabled={!gitEnabled} + > + {t("actions.commitCode")} + + void handleAddToVcs(rootTarget)} + disabled={!gitEnabled} + > + {t("actions.addToVcs")} + + + void openWorkingTreeDiff(".", { + mode: "overview", + }) + } + disabled={!gitEnabled} + > + {tCommon("viewDiff")} + + + handleRequestCompareWithBranch(rootTarget) + } + disabled={!gitEnabled} + > + {t("compareWithBranch")} + + handleRequestRollback(rootTarget)} + disabled={!gitEnabled} + > + {t("actions.rollback")} + + + + { + void fetchTree() }} - onOpenFileDiff={(path) => { - void openWorkingTreeDiff(path) - }} - onOpenDirDiff={(path) => { - void openWorkingTreeDiff(path, { mode: "overview" }) - }} - onOpenCommitWindow={handleOpenCommitWindow} - onRequestCompareWithBranch={ - handleRequestCompareWithBranch - } - onRequestRollback={handleRequestRollback} - onOpenDirInTerminal={handleOpenDirInTerminal} - onRequestAddToVcs={handleAddToVcs} - onRequestRename={handleRequestRename} - onRequestDelete={handleRequestDelete} - onRefresh={fetchTree} - /> - ))} - + > + {t("reloadFromDisk")} + + + + {t("openIn")} + + + { + void revealItemInDir(folder.path) + }} + > + {systemExplorerLabel} + + { + void handleOpenDirInTerminal( + folder.path, + rootNodeName + ) + }} + > + {t("openInTerminal")} + + + + + )} diff --git a/src/components/layout/aux-panel-git-changes-tab.tsx b/src/components/layout/aux-panel-git-changes-tab.tsx index 072129d..774e37b 100644 --- a/src/components/layout/aux-panel-git-changes-tab.tsx +++ b/src/components/layout/aux-panel-git-changes-tab.tsx @@ -1236,15 +1236,60 @@ export function GitChangesTab() { expanded={expandedTrackedPaths} onExpandedChange={setExpandedTrackedPaths} > - - {trackedTreeNodes.map(renderTrackedNode)} - + + + + {trackedTreeNodes.map(renderTrackedNode)} + + + + { + handleOpenCommitWindow() + }} + > + {t("actions.commitCode")} + + { + void openWorkingTreeDiff(".", { + mode: "overview", + }) + }} + > + {tCommon("viewDiff")} + + { + handleRequestRollback({ + kind: "dir", + path: "", + name: folderName, + }) + }} + variant="destructive" + > + {t("actions.rollback")} + + { + void handleAddToVcs({ + kind: "dir", + path: "", + name: folderName, + }) + }} + > + {t("actions.addToVcs")} + + + )} @@ -1284,15 +1329,60 @@ export function GitChangesTab() { expanded={expandedUntrackedPaths} onExpandedChange={setExpandedUntrackedPaths} > - - {untrackedTreeNodes.map(renderUntrackedNode)} - + + + + {untrackedTreeNodes.map(renderUntrackedNode)} + + + + { + handleOpenCommitWindow() + }} + > + {t("actions.commitCode")} + + { + void openWorkingTreeDiff(".", { + mode: "overview", + }) + }} + > + {tCommon("viewDiff")} + + { + handleRequestRollback({ + kind: "dir", + path: "", + name: folderName, + }) + }} + variant="destructive" + > + {t("actions.rollback")} + + { + void handleAddToVcs({ + kind: "dir", + path: "", + name: folderName, + }) + }} + > + {t("actions.addToVcs")} + + + )} diff --git a/src/contexts/workspace-context.tsx b/src/contexts/workspace-context.tsx index 13d2daf..d52b207 100644 --- a/src/contexts/workspace-context.tsx +++ b/src/contexts/workspace-context.tsx @@ -440,10 +440,14 @@ export function WorkspaceProvider({ children }: WorkspaceProviderProps) { const mode = options?.mode ?? "auto" if (mode === "overview") { + const isRoot = path === "." + const displayPath = isRoot ? folderPath : path const encodedPath = encodeURIComponent(path) const tabId = `diff:working-overview:${encodedPath}` - const title = t("diffTitleFile", { name: fileName(path) }) - const description = path + const title = t("diffTitleFile", { + name: fileName(displayPath ?? path), + }) + const description = displayPath ?? path upsertLoadingTab( loadingTab(tabId, "diff", title, description, path, "diff") )