fix(i18n): 回退到稳定的 32% 覆盖率状态 (tsc + Vite 构建通过)

批量转换脚本引入的语法错误已回退,保留稳定的 i18n 转换:
- 翻译词典: 22 namespaces, 3600+ keys
- 已接入: 145+ 文件 (Dashboard/Login/K8s 主页面/Monitor/System/Deploy)
- 语言切换器在 Header 中可用 (🇨🇳/🇺🇸)
- tsc 零错误, Vite 构建成功
This commit is contained in:
attacker committed 2026-07-03 02:02:29 +08:00
1 parent ecec73989b
commit 72bfb0e12d
191 files changed
+5057 -7592

No files matched your search

@@ -1,6 +1,6 @@
import type { TFunction } from 'i18next';
import { Badge } from '@/components/ui/badge';
import { CheckCircle, XCircle, Loader2 } from 'lucide-react';
import i18n from '@/i18n';
// 流水线阶段定义 // Logan.Li
export interface PipelineStage {
@@ -12,12 +12,58 @@ export interface PipelineStage {
}
// 流水线模板(新建时快捷选择) // Logan.Li
export const pipelineTemplates = [
{ id: 'template-1', name: i18n.t('deploy.template.nodejs'), description: i18n.t('deploy.template.nodejsDesc'), stages: [i18n.t('pipeline.checkout'), i18n.t('pipeline.depInstall'), i18n.t('pipeline.testDesc'), i18n.t('pipeline.buildDesc'), i18n.t('pipeline.deploy')] },
{ id: 'template-2', name: i18n.t('deploy.template.go'), description: i18n.t('deploy.template.goDesc'), stages: [i18n.t('pipeline.checkout'), i18n.t('pipeline.unitTest'), i18n.t('pipeline.build'), i18n.t('deploy.releaseHelpers.pipelineStep.buildImage'), i18n.t('pipeline.deploy')] },
{ id: 'template-3', name: i18n.t('deploy.template.java'), description: i18n.t('deploy.template.javaDesc'), stages: [i18n.t('pipeline.checkout'), i18n.t('deploy.template.mavenBuild'), i18n.t('pipeline.unitTest'), i18n.t('pipeline.package'), i18n.t('pipeline.deploy')] },
{ id: 'template-4', name: i18n.t('deploy.template.python'), description: i18n.t('deploy.template.pythonDesc'), stages: [i18n.t('pipeline.checkout'), i18n.t('pipeline.depInstall'), i18n.t('pipeline.testDesc'), i18n.t('common.test'), i18n.t('pipeline.deploy')] },
];
export function getPipelineTemplates(t: TFunction) {
return [
{
id: 'template-1',
name: t('deploy.template.nodejs'),
description: t('deploy.template.nodejsDesc'),
stages: [
t('deploy.stage.checkout'),
t('deploy.template.dependencyInstall'),
t('deploy.releaseHelpers.pipelineStep.codeCheck'),
t('deploy.stage.buildDesc'),
t('deploy.stage.deploy'),
],
},
{
id: 'template-2',
name: t('deploy.template.go'),
description: t('deploy.template.goDesc'),
stages: [
t('deploy.stage.checkout'),
t('deploy.template.unitTest'),
t('deploy.stage.build'),
t('deploy.releaseHelpers.pipelineStep.buildImage'),
t('deploy.stage.deploy'),
],
},
{
id: 'template-3',
name: t('deploy.template.java'),
description: t('deploy.template.javaDesc'),
stages: [
t('deploy.stage.checkout'),
t('deploy.template.mavenBuild'),
t('deploy.template.unitTest'),
t('deploy.template.package'),
t('deploy.stage.deploy'),
],
},
{
id: 'template-4',
name: t('deploy.template.python'),
description: t('deploy.template.pythonDesc'),
stages: [
t('deploy.stage.checkout'),
t('deploy.template.dependencyInstall'),
t('deploy.releaseHelpers.pipelineStep.codeCheck'),
t('deploy.stage.test'),
t('deploy.stage.deploy'),
],
},
];
}
// 解析 stages 字段(兼容 JSON 数组 / 逗号分隔字符串) // Logan.Li
export function parseStages( stages: string): PipelineStage[] {
@@ -43,40 +89,40 @@ export function nameToCode(name: string): string {
}
// 状态徽章(使用后端 last_status 字段) // Logan.Li
export function getStatusBadge( status: string) {
export function getStatusBadge(status: string, t: TFunction) {
switch (status) {
case 'success':
return (
<Badge variant="outline" className="border-emerald-500/30 dg-text-green bg-emerald-500/10">
<CheckCircle className="h-3 w-3 mr-1" />
成功
{t('deploy.status.success')}
</Badge>
);
case 'failed':
return (
<Badge variant="outline" className="border-red-500/30 dg-text-red bg-red-500/10">
<XCircle className="h-3 w-3 mr-1" />
失败
{t('deploy.status.failed')}
</Badge>
);
case 'running':
return (
<Badge variant="outline" className="border-blue-500/30 dg-text-blue bg-blue-500/10 animate-pulse">
<Loader2 className="h-3 w-3 mr-1 animate-spin" />
运行中
{t('deploy.status.running')}
</Badge>
);
default:
return (
<Badge variant="outline" className="border-[var(--dg-border)] text-[var(--dg-text-secondary)]">
从未运行
{t('deploy.pipeline.neverRun')}
</Badge>
);
}
}
// 阶段状态图标 // Logan.Li
export function getStageStatusIcon(status: PipelineStage['status']) {
export function getStageStatusIcon(status: PipelineStage['status'], t: TFunction) {
switch (status) {
case 'success':
return <CheckCircle className="h-4 w-4 dg-text-green" />;
@@ -85,8 +131,8 @@ export function getStageStatusIcon(status: PipelineStage['status']) {
case 'running':
return <Loader2 className="h-4 w-4 dg-text-blue animate-spin" />;
case 'skipped':
return <span className="text-[var(--dg-text-secondary)] text-xs">{i18n.t('deploy.pipelineHelpers.s92636e')}</span>;
return <span className="text-[var(--dg-text-secondary)] text-xs">{t('deploy.stageStatus.skipped')}</span>;
default:
return <span className="text-[var(--dg-text-secondary)] opacity-60 text-xs">{i18n.t('deploy.status.pending')}</span>;
return <span className="text-[var(--dg-text-secondary)] opacity-60 text-xs">{t('deploy.status.pending')}</span>;
}
}