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

+24 -21
View File
@@ -23,6 +23,7 @@ import {
} from '@/components/ui/dialog';
import {
import { useTranslation } from 'react-i18next';
Cpu,
MemoryStick,
HardDrive,
@@ -41,6 +42,7 @@ import {
// ============ 组件 ============
export function AgentMonitor() {
const { t } = useTranslation();
const [hosts, setHosts] = useState<AgentHostRecord[]>([]);
const [loading, setLoading] = useState(true);
const [refreshing, setRefreshing] = useState(false);
@@ -68,7 +70,7 @@ export function AgentMonitor() {
if (fresh) setSelectedHost(fresh);
}
} catch (err) {
if (!silent) toast.error('加载主机列表失败');
if (!silent) toast.error(t('agent.agentmonitor.s5760f6'));
console.error(err);
} finally {
setLoading(false);
@@ -97,7 +99,7 @@ export function AgentMonitor() {
// 提交远程命令(直连 SSH 即时返回)
const submitCommand = async () => {
if (!cmdCommand.trim()) {
toast.error('请输入要执行的命令');
toast.error(t('agent.agentmonitor.s9358aa'));
return;
}
setCmdSubmitting(true);
@@ -111,11 +113,11 @@ export function AgentMonitor() {
const resData = (res?.data ?? {}) as Record<string, unknown>;
setCmdResult({
status: res?.code === 200 ? 'completed' : 'failed',
result: (resData.output as string) || (res?.message as string) || '无输出',
result: (resData.output as string) || (res?.message as string) || t('agent.agentmonitor.s26d45b'),
error: resData.error as string | undefined,
});
} catch (err) {
setCmdResult({ status: 'failed', result: err?.message || '执行失败' });
setCmdResult({ status: 'failed', result: err?.message || t('automation.scriptFailed') });
} finally {
setCmdSubmitting(false);
loadLatest(true);
@@ -129,9 +131,9 @@ export function AgentMonitor() {
const onlineCount = hosts.filter((h) => isOnline(h.last_report || h.last_reported_at || h.updated_at)).length;
const stats = [
{ label: '主机总数', value: hosts.length, icon: Server, color: 'dg-text-blue' },
{ label: '在线', value: onlineCount, icon: Wifi, color: 'dg-text-green' },
{ label: '离线', value: hosts.length - onlineCount, icon: WifiOff, color: 'dg-text-red' },
{ label: t('agent.agentmonitor.sd94cd2'), value: hosts.length, icon: Server, color: 'dg-text-blue' },
{ label: t('common.online'), value: onlineCount, icon: Wifi, color: 'dg-text-green' },
{ label: t('common.offline'), value: hosts.length - onlineCount, icon: WifiOff, color: 'dg-text-red' },
];
return (
@@ -139,8 +141,8 @@ export function AgentMonitor() {
{/* 页头 */}
<div className="flex items-center justify-between">
<div>
<h2 className="text-xl font-semibold text-[var(--dg-text-primary)]">Agent 监控</h2>
<p className="text-sm dg-text-secondary mt-0.5">实时监控 Agent 上报的主机指标</p>
<h2 className="text-xl font-semibold text-[var(--dg-text-primary)]">{t('agent.agentMonitor')}</h2>
<p className="text-sm dg-text-secondary mt-0.5">{t('agent.agentmonitor.sa75d75')}</p>
</div>
<div className="flex items-center gap-2">
<Button
@@ -186,14 +188,14 @@ export function AgentMonitor() {
<Card className="dg-card">
<CardContent className="flex items-center justify-center py-16">
<Loader2 className="h-6 w-6 animate-spin dg-text-muted" />
<span className="ml-2 dg-text-secondary">加载中...</span>
<span className="ml-2 dg-text-secondary">{t('common.loading')}</span>
</CardContent>
</Card>
) : hosts.length === 0 ? (
<Card className="dg-card">
<CardContent className="flex flex-col items-center justify-center py-16">
<Server className="h-10 w-10 dg-text-muted mb-3" />
<p className="dg-text-secondary">暂无 Agent 上报数据</p>
<p className="dg-text-secondary">{t('agent.noAgentData')}</p>
<Button
size="sm"
onClick={() => setWizardOpen(true)}
@@ -240,8 +242,8 @@ export function AgentMonitor() {
{/* 指标条 */}
<div className="space-y-2">
<MetricBar icon={Cpu} label="CPU" value={cpu} />
<MetricBar icon={MemoryStick} label="内存" value={mem} />
<MetricBar icon={HardDrive} label="磁盘" value={disk} />
<MetricBar icon={MemoryStick} label=t('k8s.pods.memory') value={mem} />
<MetricBar icon={HardDrive} label=t('dashboard.topUsage.disk') value={disk} />
</div>
{/* 端口 & 时间 */}
@@ -307,7 +309,7 @@ export function AgentMonitor() {
<div className="space-y-3">
<div className="grid grid-cols-2 gap-3">
<div className="space-y-1.5">
<Label className="text-[var(--dg-text-secondary)] text-xs">目标主机</Label>
<Label className="text-[var(--dg-text-secondary)] text-xs">{t('agent.installTarget')}</Label>
<Input
value={cmdHost}
onChange={(e) => setCmdHost(e.target.value)}
@@ -318,18 +320,18 @@ export function AgentMonitor() {
</div>
<div className="space-y-1.5">
<Label className="text-[var(--dg-text-secondary)] text-xs">命令</Label>
<Label className="text-[var(--dg-text-secondary)] text-xs">{t('system.terminalCommand')}</Label>
<Textarea
value={cmdCommand}
onChange={(e) => setCmdCommand(e.target.value)}
placeholder="例如:free -m && df -h"
placeholder=t('agent.agentmonitor.s6e62a5')
rows={3}
className="bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] font-mono text-sm resize-none"
/>
</div>
<div className="w-40 space-y-1.5">
<Label className="text-[var(--dg-text-secondary)] text-xs">超时(秒)</Label>
<Label className="text-[var(--dg-text-secondary)] text-xs">{t('monitor.probeTimeout')}</Label>
<Input
type="number"
value={cmdTimeout}
@@ -342,7 +344,7 @@ export function AgentMonitor() {
{cmdResult && (
<div className="space-y-1.5">
<div className="flex items-center gap-2">
<Label className="text-[var(--dg-text-secondary)] text-xs">执行结果</Label>
<Label className="text-[var(--dg-text-secondary)] text-xs">{t('automation.execResult')}</Label>
<Badge
className={
cmdResult.status === 'success' || cmdResult.status === 'done' || cmdResult.status === 'completed'
@@ -356,7 +358,7 @@ export function AgentMonitor() {
</Badge>
</div>
<pre className="text-xs text-[var(--dg-text-secondary)] font-mono whitespace-pre-wrap break-all bg-[var(--dg-bg-primary)] border border-[var(--dg-border)] rounded-lg p-3 max-h-48 overflow-auto">
{cmdResult.result || cmdResult.output || cmdResult.error || '无输出'}
{cmdResult.result || cmdResult.output || cmdResult.error || t('agent.agentmonitor.s26d45b')}
</pre>
</div>
)}
@@ -372,9 +374,9 @@ export function AgentMonitor() {
className="bg-blue-600 hover:bg-blue-700 text-white"
>
{cmdSubmitting ? (
<><Loader2 className="h-4 w-4 mr-1.5 animate-spin" />执行中</>
<><Loader2 className="h-4 w-4 mr-1.5 animate-spin" />{t('common.executing')}</>
) : (
<><Terminal className="h-4 w-4 mr-1.5" />执行</>
<><Terminal className="h-4 w-4 mr-1.5" />{t('common.execute')}</>
)}
</Button>
</DialogFooter>
@@ -389,6 +391,7 @@ export function AgentMonitor() {
// ============ 指标条子组件 ============
function MetricBar({ icon: Icon, label, value }: { icon: ComponentType<{ className?: string }>; label: string; value: number }) {
const { t } = useTranslation();
return (
<div className="flex items-center gap-2">
<Icon className="h-3.5 w-3.5 dg-text-muted shrink-0" />