git页面修复

This commit is contained in:
2025-08-09 23:10:29 +08:00
parent 272ea62bee
commit dbda05e688
3 changed files with 60 additions and 40 deletions

View File

@@ -39,6 +39,8 @@ import {
TooltipProvider, TooltipProvider,
TooltipTrigger, TooltipTrigger,
} from "@/components/ui/tooltip"; } from "@/components/ui/tooltip";
import { useTranslation } from "@/hooks/useTranslation";
interface GitFileStatus { interface GitFileStatus {
path: string; path: string;
@@ -143,6 +145,8 @@ export const GitPanelEnhanced: React.FC<GitPanelEnhancedProps> = ({
const panelRef = useRef<HTMLDivElement>(null); const panelRef = useRef<HTMLDivElement>(null);
const resizeHandleRef = useRef<HTMLDivElement>(null); const resizeHandleRef = useRef<HTMLDivElement>(null);
const { t } = useTranslation();
const refreshIntervalRef = useRef<NodeJS.Timeout | null>(null); const refreshIntervalRef = useRef<NodeJS.Timeout | null>(null);
// 处理拖拽调整宽度 // 处理拖拽调整宽度
@@ -535,10 +539,10 @@ export const GitPanelEnhanced: React.FC<GitPanelEnhancedProps> = ({
<div className="flex items-center gap-2 px-2 py-1 text-xs font-medium text-muted-foreground sticky top-0 bg-background z-10"> <div className="flex items-center gap-2 px-2 py-1 text-xs font-medium text-muted-foreground sticky top-0 bg-background z-10">
{getFileStatusIcon(statusType)} {getFileStatusIcon(statusType)}
<span> <span>
{statusType === 'modified' && '已修改'} {statusType === 'modified' && t('app.modified')}
{statusType === 'staged' && '已暂存'} {statusType === 'staged' && t('app.staged')}
{statusType === 'untracked' && '未跟踪'} {statusType === 'untracked' && t('app.untracked')}
{statusType === 'conflicted' && '冲突'} {statusType === 'conflicted' && t('app.conflicted')}
</span> </span>
<Badge variant="secondary" className="ml-auto"> <Badge variant="secondary" className="ml-auto">
{files.length} {files.length}
@@ -558,7 +562,7 @@ export const GitPanelEnhanced: React.FC<GitPanelEnhancedProps> = ({
return ( return (
<div className="flex flex-col items-center justify-center py-8 text-muted-foreground"> <div className="flex flex-col items-center justify-center py-8 text-muted-foreground">
<GitCommit className="h-8 w-8 mb-2" /> <GitCommit className="h-8 w-8 mb-2" />
<p className="text-sm"></p> <p className="text-sm">{t('app.noCommitsFound')}</p>
</div> </div>
); );
} }
@@ -588,7 +592,7 @@ export const GitPanelEnhanced: React.FC<GitPanelEnhancedProps> = ({
</code> </code>
{commit.files_changed > 0 && ( {commit.files_changed > 0 && (
<span className="text-xs text-muted-foreground"> <span className="text-xs text-muted-foreground">
{commit.files_changed} files {commit.files_changed} {t('app.filesChanged')}
</span> </span>
)} )}
</div> </div>
@@ -640,7 +644,7 @@ export const GitPanelEnhanced: React.FC<GitPanelEnhancedProps> = ({
<div className="flex items-center justify-between p-3 border-b"> <div className="flex items-center justify-between p-3 border-b">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<GitBranch className="h-4 w-4 text-muted-foreground" /> <GitBranch className="h-4 w-4 text-muted-foreground" />
<h3 className="font-medium text-sm">Git</h3> <h3 className="font-medium text-sm">{t('app.gitPanel')}</h3>
{gitStatus && ( {gitStatus && (
<Badge variant="outline" className="text-xs"> <Badge variant="outline" className="text-xs">
{gitStatus.branch} {gitStatus.branch}
@@ -662,7 +666,7 @@ export const GitPanelEnhanced: React.FC<GitPanelEnhancedProps> = ({
</Button> </Button>
</TooltipTrigger> </TooltipTrigger>
<TooltipContent> <TooltipContent>
<p>{selectedPath ? '展开当前文件夹' : '展开所有文件夹'}</p> <p>{selectedPath ? t('app.expandCurrentFolder') : t('app.expandAllFolders')}</p>
</TooltipContent> </TooltipContent>
</Tooltip> </Tooltip>
</TooltipProvider> </TooltipProvider>
@@ -680,14 +684,14 @@ export const GitPanelEnhanced: React.FC<GitPanelEnhancedProps> = ({
</Button> </Button>
</TooltipTrigger> </TooltipTrigger>
<TooltipContent> <TooltipContent>
<p>{selectedPath ? '收起当前文件夹' : '收起所有文件夹'}</p> <p>{selectedPath ? t('app.collapseCurrentFolder') : t('app.collapseAllFolders')}</p>
</TooltipContent> </TooltipContent>
</Tooltip> </Tooltip>
</TooltipProvider> </TooltipProvider>
{changeStats && changeStats.total > 0 && ( {changeStats && changeStats.total > 0 && (
<Badge variant="destructive" className="text-xs"> <Badge variant="destructive" className="text-xs">
{changeStats.total} {changeStats.total} {t('app.gitChanges')}
</Badge> </Badge>
)} )}
<Button <Button
@@ -721,13 +725,13 @@ export const GitPanelEnhanced: React.FC<GitPanelEnhancedProps> = ({
{gitStatus.ahead > 0 && ( {gitStatus.ahead > 0 && (
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">
<GitPullRequest className="h-3 w-3 text-green-500" /> <GitPullRequest className="h-3 w-3 text-green-500" />
<span>{gitStatus.ahead} ahead</span> <span>{gitStatus.ahead} {t('app.ahead')}</span>
</div> </div>
)} )}
{gitStatus.behind > 0 && ( {gitStatus.behind > 0 && (
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">
<GitMerge className="h-3 w-3 text-blue-500" /> <GitMerge className="h-3 w-3 text-blue-500" />
<span>{gitStatus.behind} behind</span> <span>{gitStatus.behind} {t('app.behind')}</span>
</div> </div>
)} )}
</div> </div>
@@ -739,7 +743,7 @@ export const GitPanelEnhanced: React.FC<GitPanelEnhancedProps> = ({
<TabsList className="w-full rounded-none border-b"> <TabsList className="w-full rounded-none border-b">
<TabsTrigger value="changes" className="flex-1 gap-2"> <TabsTrigger value="changes" className="flex-1 gap-2">
<FileDiff className="h-4 w-4" /> <FileDiff className="h-4 w-4" />
{t('app.gitChanges')}
{changeStats && changeStats.total > 0 && ( {changeStats && changeStats.total > 0 && (
<Badge variant="secondary" className="ml-1"> <Badge variant="secondary" className="ml-1">
{changeStats.total} {changeStats.total}
@@ -748,7 +752,7 @@ export const GitPanelEnhanced: React.FC<GitPanelEnhancedProps> = ({
</TabsTrigger> </TabsTrigger>
<TabsTrigger value="history" className="flex-1 gap-2"> <TabsTrigger value="history" className="flex-1 gap-2">
<GitCommit className="h-4 w-4" /> <GitCommit className="h-4 w-4" />
{t('app.gitHistory')}
</TabsTrigger> </TabsTrigger>
</TabsList> </TabsList>
@@ -777,7 +781,7 @@ export const GitPanelEnhanced: React.FC<GitPanelEnhancedProps> = ({
{changeStats?.total === 0 && ( {changeStats?.total === 0 && (
<div className="flex flex-col items-center justify-center py-8 text-muted-foreground"> <div className="flex flex-col items-center justify-center py-8 text-muted-foreground">
<Check className="h-8 w-8 mb-2 text-green-500" /> <Check className="h-8 w-8 mb-2 text-green-500" />
<p className="text-sm"></p> <p className="text-sm">{t('app.workingTreeClean')}</p>
</div> </div>
)} )}
</> </>

View File

@@ -73,6 +73,14 @@
"saved": "Saved", "saved": "Saved",
"unsavedChangesConfirm": "You have unsaved changes. Are you sure you want to leave?", "unsavedChangesConfirm": "You have unsaved changes. Are you sure you want to leave?",
"gitPanel": "Git", "gitPanel": "Git",
"gitChanges": "Changes",
"expandCurrentFolder": "Expand current folder",
"expandAllFolders": "Expand all folders",
"collapseCurrentFolder": "Collapse current folder",
"collapseAllFolders": "Collapse all folders",
"ahead": "ahead",
"behind": "behind",
"gitStatus": "Status", "gitStatus": "Status",
"gitHistory": "History", "gitHistory": "History",
"gitBranches": "Branches", "gitBranches": "Branches",

View File

@@ -73,6 +73,14 @@
"gitStatus": "状态", "gitStatus": "状态",
"gitHistory": "历史", "gitHistory": "历史",
"gitBranches": "分支", "gitBranches": "分支",
"gitChanges": "变更",
"expandCurrentFolder": "展开当前文件夹",
"expandAllFolders": "展开所有文件夹",
"collapseCurrentFolder": "收起当前文件夹",
"collapseAllFolders": "收起所有文件夹",
"ahead": "领先",
"behind": "落后",
"workingTreeClean": "工作区清洁", "workingTreeClean": "工作区清洁",
"staged": "已暂存", "staged": "已暂存",
"modified": "已修改", "modified": "已修改",