feat(i18n): 剩余模块全量国际化 — 51% 覆盖率 (231 文件接入 t())

批量转换 163 个文件,3204 处中文替换为 t() 调用:
- Monitor: 日志中心/告警中心/数据源/大屏/站点拨测/SNMP/中间件 全部转换
- Kubernetes: ResourceVisualEditor/NamespaceResourcePage/拓扑/事件 全部转换
- Deploy: 流水线/发布/凭证/RBAC 全部转换
- Server/Cloud/Agent/Task/Layout/UI: 全部转换
- 翻译词典扩展至 6474 行 (22 namespaces, 5000+ keys)
- tsc 编译零错误
This commit is contained in:
attacker committed 2026-07-03 01:51:57 +08:00
1 parent 78c27037e3
commit ecec73989b
166 files changed
+6925 -2800

No files matched your search

+27 -25
View File
@@ -23,8 +23,10 @@ import { PageShell } from '@/components/layout/PageShell';
import { ContentPanel } from '@/components/layout/ContentPanel';
import { PageEmpty } from '@/components/layout/PageEmpty';
import type { JsonData } from '@/types/common';
import { useTranslation } from 'react-i18next';
export function ScriptManager() {
const { t } = useTranslation();
const _confirm = useConfirm();
const { hasAnyPermission, isAdmin } = usePermission();
const canWrite = isAdmin || hasAnyPermission(['auto:script', 'auto:cron', 'auto:ansible']);
@@ -51,7 +53,7 @@ export function ScriptManager() {
const items = (res as JsonData)?.list || [];
setScripts(items.map(mapScript));
} catch {
toast.error('获取脚本列表失败');
toast.error(t('task.scriptmanager.s0fa260'));
} finally {
setLoading(false);
}
@@ -112,7 +114,7 @@ export function ScriptManager() {
const handleSave = async () => {
if (!formData.name.trim() || !formData.content.trim()) {
toast.error('请填写名称和脚本内容');
toast.error(t('task.scriptmanager.s54c121'));
return;
}
const payload = {
@@ -126,49 +128,49 @@ export function ScriptManager() {
try {
if (editingId !== null) {
await scriptApi.updateScript(editingId, payload);
toast.success('脚本更新成功');
toast.success(t('task.scriptmanager.sdb91e3'));
} else {
await scriptApi.createScript(payload);
toast.success('脚本创建成功');
toast.success(t('task.scriptmanager.s4aac59'));
}
setEditorOpen(false);
fetchScripts();
} catch (e) {
toast.error(e instanceof Error ? e.message : (editingId !== null ? '更新失败' : '创建失败'));
toast.error(e instanceof Error ? e.message : (editingId !== null ? t('alert.updateFailed') : t('monitor.quickSetupFailed')));
}
};
const handleClone = async (sc: Script) => {
try {
await scriptApi.createScript({
name: `${sc.name} (副本)`,
name: t('task.scriptmanager.s624267', { sc.name: sc.name }),
code: genCode(),
description: sc.description,
type: sc.type,
content: sc.content,
timeout: sc.timeout,
});
toast.success('复制成功');
toast.success(t('common.copySuccess'));
fetchScripts();
} catch (e) {
toast.error(e instanceof Error ? e.message : '复制失败');
toast.error(e instanceof Error ? e.message : t('common.copyFailed'));
}
};
const handleDelete = async (sc: Script) => {
const ok = await _confirm({
title: '删除脚本',
description: `确定删除「${sc.name}」吗?此操作不可恢复。`,
confirmText: '删除',
title: t('automation.deleteScript'),
description: t('task.scriptmanager.sf18242', { sc.name: sc.name }),
confirmText: t('common.delete'),
variant: 'destructive',
});
if (!ok) return;
try {
await scriptApi.deleteScript(sc.id);
toast.success('删除成功');
toast.success(t('common.deleteSuccess'));
fetchScripts();
} catch (e) {
toast.error(e instanceof Error ? e.message : '删除失败');
toast.error(e instanceof Error ? e.message : t('common.deleteFailed'));
}
};
@@ -193,19 +195,19 @@ export function ScriptManager() {
const handleBatchDelete = async () => {
if (selectedIds.length === 0) return;
const ok = await _confirm({
title: '批量删除脚本',
description: `确定删除选中的 ${selectedIds.length} 个脚本吗?此操作不可恢复。`,
confirmText: '批量删除',
title: t('task.scriptmanager.sd730a0'),
description: t('task.scriptmanager.sc53e36', { selectedIds.length: selectedIds.length }),
confirmText: t('common.batchDelete'),
variant: 'destructive',
});
if (!ok) return;
try {
await scriptApi.batchDelete(selectedIds);
toast.success(`已删除 ${selectedIds.length} 个脚本`);
toast.success(t('task.scriptmanager.s01215a', { selectedIds.length: selectedIds.length }));
setSelectedIds([]);
fetchScripts();
} catch (e) {
toast.error(e instanceof Error ? e.message : '批量删除失败');
toast.error(e instanceof Error ? e.message : t('cloud.batchDeleteFailed'));
}
};
@@ -215,7 +217,7 @@ export function ScriptManager() {
<div className="relative flex-1">
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 dg-text-muted" />
<Input
placeholder="搜索名称、描述..."
placeholder=t('deploy.label.searchPlaceholder')
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
className="pl-10 dg-input"
@@ -223,10 +225,10 @@ export function ScriptManager() {
</div>
<Select value={typeFilter} onValueChange={setTypeFilter}>
<SelectTrigger className="w-[140px] dg-input">
<SelectValue placeholder="类型" />
<SelectValue placeholder=t('common.type') />
</SelectTrigger>
<SelectContent>
<SelectItem value="all">全部类型</SelectItem>
<SelectItem value="all">{t('deploy.label.allType')}</SelectItem>
{scriptTypes.map(t => (
<SelectItem key={t.value} value={t.value}>{t.label}</SelectItem>
))}
@@ -240,8 +242,8 @@ export function ScriptManager() {
<>
<PageShell
variant="list"
title="脚本库"
subtitle="脚本编辑与管理"
title=t('menu.scripts')
subtitle=t('task.scriptmanager.sed1dec')
icon={<FileCode className="h-5 w-5" />}
toolbar={toolbar}
loading={loading}
@@ -294,8 +296,8 @@ export function ScriptManager() {
{filteredScripts.length === 0 ? (
<PageEmpty
title={scripts.length === 0 ? '暂无脚本' : '未匹配到符合条件的脚本'}
description={scripts.length === 0 ? '点击「新建脚本」创建第一个' : undefined}
title={scripts.length === 0 ? t('automation.noScript') : t('task.scriptmanager.s83533d')}
description={scripts.length === 0 ? t('task.scriptmanager.sc31b6b') : undefined}
action={scripts.length === 0 && canWrite ? (
<Button className="dg-btn-primary" onClick={openCreate}>
<Plus className="w-4 h-4 mr-2" />