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

@@ -22,15 +22,13 @@ import { Badge } from '@/components/ui/badge';
import { toast } from 'sonner';
import { cronJobApi, scriptApi } from '@/api';
import type { JsonData } from '@/types/common';
import { useTranslation } from 'react-i18next';
import i18n from '@/i18n';
// 定时任务类型定义 // Logan.Li
const jobTypes = [
{ value: 'shell', label: 'Shell', desc: i18n.t('task.cronjobformdialog.s570531') },
{ value: 'python', label: 'Python', desc: i18n.t('task.cronjobformdialog.s021fae') },
{ value: 'powershell', label: 'PowerShell', desc: i18n.t('task.cronjobformdialog.s783cca') },
{ value: 'command', label: i18n.t('task.cronjobformdialog.sad6526'), desc: i18n.t('task.cronjobformdialog.s492a4c') },
{ value: 'shell', label: 'Shell', desc: '关联脚本库中的 Shell 脚本' },
{ value: 'python', label: 'Python', desc: '关联脚本库中的 Python 脚本' },
{ value: 'powershell', label: 'PowerShell', desc: '关联脚本库中的 PowerShell 脚本' },
{ value: 'command', label: '自定义命令', desc: '手动输入命令或脚本路径' },
];
const scriptJobTypes = ['shell', 'python', 'powershell'];
@@ -52,7 +50,6 @@ export function CronJobFormDialog({
editJob: JsonData | null;
onSuccess: () => void;
}) {
const { t } = useTranslation();
const [form, setForm] = useState({
name: '',
description: '',
@@ -123,12 +120,12 @@ export function CronJobFormDialog({
const handleSave = async () => {
if (!form.name || !form.cron_expr) {
toast.error(t('task.cronjobformdialog.s69fb01'));
toast.error('请填写任务名称和 Cron 表达式');
return;
}
// 脚本类型必须选关联脚本 // Logan.Li
if (scriptJobTypes.includes(form.type) && !form.script_id) {
toast.error(t('task.cronjobformdialog.sd4df29'));
toast.error('请选择关联的脚本');
return;
}
try {
@@ -143,16 +140,16 @@ export function CronJobFormDialog({
};
if (editJob) {
await cronJobApi.updateJob(editJob.id, payload);
toast.success(t('task.cronjobformdialog.s8398c3'));
toast.success('任务更新成功');
} else {
await cronJobApi.createJob(payload);
toast.success(t('task.cronjobformdialog.s3799bd'));
toast.success('任务创建成功');
}
onOpenChange(false);
onSuccess();
} catch (error) {
console.error('Failed to save cron job:', error);
toast.error(editJob ? t('alert.updateFailed') : t('monitor.quickSetupFailed'));
toast.error(editJob ? '更新失败' : '创建失败');
} finally {
setSubmitting(false);
}
@@ -162,28 +159,28 @@ export function CronJobFormDialog({
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-2xl bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]">
<DialogHeader>
<DialogTitle>{editJob ? t('automation.editCronJob') : t('task.cronjobformdialog.s1b9746')}</DialogTitle>
<DialogDescription className="text-[var(--dg-text-secondary)]">{t('task.cronjobformdialog.s2e10ee')}</DialogDescription>
<DialogTitle>{editJob ? '编辑定时任务' : '新建定时任务'}</DialogTitle>
<DialogDescription className="text-[var(--dg-text-secondary)]">配置 Cron 定时任务</DialogDescription>
</DialogHeader>
<div className="space-y-4 py-4 max-h-[60vh] overflow-y-auto pr-1">
{/* 任务名称 */}
<div>
<Label className="text-[var(--dg-text-primary)]">{t('monitor.probeName')}</Label>
<Label className="text-[var(--dg-text-primary)]">任务名称</Label>
<Input
value={form.name}
onChange={(e) => setForm({ ...form, name: e.target.value })}
placeholder=t('task.cronjobformdialog.s2c69d3')
placeholder="例如: 数据库备份"
className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] mt-1"
/>
</div>
{/* 描述 */}
<div>
<Label className="text-[var(--dg-text-primary)]">{t('common.description')}</Label>
<Label className="text-[var(--dg-text-primary)]">描述</Label>
<Textarea
value={form.description}
onChange={(e) => setForm({ ...form, description: e.target.value })}
placeholder=t('task.cronjobformdialog.s405de0')
placeholder="任务描述..."
rows={2}
className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] mt-1"
/>
@@ -191,7 +188,7 @@ export function CronJobFormDialog({
{/* Cron 表达式 */}
<div>
<Label className="text-[var(--dg-text-primary)]">{t('pipeline.cronExpr')}</Label>
<Label className="text-[var(--dg-text-primary)]">Cron 表达式</Label>
<div className="flex gap-2">
<Input
value={form.cron_expr}
@@ -201,23 +198,23 @@ export function CronJobFormDialog({
/>
<Select onValueChange={(v) => setForm({ ...form, cron_expr: v })}>
<SelectTrigger className="w-48 bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] mt-1">
<SelectValue placeholder=t('task.cronjobformdialog.s1b054b') />
<SelectValue placeholder="快速选择" />
</SelectTrigger>
<SelectContent className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]">
<SelectItem value="*/5 * * * *" className="text-[var(--dg-text-primary)]">{t('task.cronJob.cron.every5min')}</SelectItem>
<SelectItem value="0 * * * *" className="text-[var(--dg-text-primary)]">{t('deploy.trigger.everyHour')}</SelectItem>
<SelectItem value="0 2 * * *" className="text-[var(--dg-text-primary)]">{t('task.cronJob.cron.daily2')}</SelectItem>
<SelectItem value="0 3 * * 0" className="text-[var(--dg-text-primary)]">{t('task.cronJob.cron.weeklySun3')}</SelectItem>
<SelectItem value="0 9 * * 1" className="text-[var(--dg-text-primary)]">{t('task.cronJob.cron.weeklyMon9')}</SelectItem>
<SelectItem value="*/5 * * * *" className="text-[var(--dg-text-primary)]">每 5 分钟</SelectItem>
<SelectItem value="0 * * * *" className="text-[var(--dg-text-primary)]">每小时</SelectItem>
<SelectItem value="0 2 * * *" className="text-[var(--dg-text-primary)]">每天 02:00</SelectItem>
<SelectItem value="0 3 * * 0" className="text-[var(--dg-text-primary)]">每周日 03:00</SelectItem>
<SelectItem value="0 9 * * 1" className="text-[var(--dg-text-primary)]">每周一 09:00</SelectItem>
</SelectContent>
</Select>
</div>
<p className="text-xs text-[var(--dg-text-muted)] mt-1">{t('task.cronjobformdialog.s3b56b1')}</p>
<p className="text-xs text-[var(--dg-text-muted)] mt-1">格式: 分 时 日 月 周</p>
</div>
{/* 执行类型 */}
<div>
<Label className="text-[var(--dg-text-primary)]">{t('task.cronjobformdialog.s15d864')}</Label>
<Label className="text-[var(--dg-text-primary)]">执行类型</Label>
<div className="grid grid-cols-2 sm:grid-cols-4 gap-2 mt-1">
{jobTypes.map(t => (
<button
@@ -261,7 +258,7 @@ export function CronJobFormDialog({
onValueChange={handleSelectScript}
>
<SelectTrigger className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] mt-1">
<SelectValue placeholder=t('task.cronjobformdialog.s3e4f7c') />
<SelectValue placeholder="选择脚本库中的脚本..." />
</SelectTrigger>
<SelectContent className="bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]">
{filteredScripts.map(sc => (
@@ -286,14 +283,14 @@ export function CronJobFormDialog({
</span>
</div>
<pre className="max-h-48 overflow-auto rounded-md bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] p-3 text-xs font-mono text-[var(--dg-text-secondary)] whitespace-pre-wrap break-all">
{selectedScript.content || t('task.cronjobformdialog.s331ff8')}
{selectedScript.content || '(空脚本)'}
</pre>
</div>
)}
</div>
) : (
<div>
<Label className="text-[var(--dg-text-primary)]">{t('kubernetes.pod.exec')}</Label>
<Label className="text-[var(--dg-text-primary)]">执行命令</Label>
<Textarea
value={form.content}
onChange={(e) => setForm({ ...form, content: e.target.value })}
@@ -313,7 +310,7 @@ export function CronJobFormDialog({
onClick={handleSave}
disabled={submitting}
>
{submitting ? i18n.t('k8s.topology.saving') : editJob ? i18n.t('cloud.saveChanges') : i18n.t('task.cronjobformdialog.s6ef95f')}
{submitting ? '保存中...' : editJob ? '保存修改' : '创建任务'}
</Button>
</DialogFooter>
</DialogContent>