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

View File

@@ -73,6 +73,14 @@
"saved": "Saved",
"unsavedChangesConfirm": "You have unsaved changes. Are you sure you want to leave?",
"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",
"gitHistory": "History",
"gitBranches": "Branches",

View File

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