diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index eac7029..6f5afc2 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -9,6 +9,7 @@ import { ProtectedRoute } from '@/components/auth/ProtectedRoute'; import { PageTransition } from '@/components/layout/PageTransition'; import { ErrorBoundary } from '@/components/layout/ErrorBoundary'; import { Toaster } from '@/components/ui/sonner'; +import i18n from '@/i18n'; // Lazy load page components for code splitting const Dashboard = lazy(() => import('@/components/dashboard/Dashboard').then(m => ({ default: m.Dashboard }))); @@ -75,7 +76,7 @@ function PageLoader() {
-

加载中...

+

{i18n.t('monitor.logPanel.logResults.loading')}

); } diff --git a/frontend/src/api/aiops/assistant.ts b/frontend/src/api/aiops/assistant.ts index 590de37..214e954 100644 --- a/frontend/src/api/aiops/assistant.ts +++ b/frontend/src/api/aiops/assistant.ts @@ -4,6 +4,7 @@ import { http } from '@/utils/request'; import { clearToken } from '@/utils/storage'; import { useUserStore } from '@/store'; +import i18n from '@/i18n'; export interface LLMConfigData { configured?: boolean; @@ -74,9 +75,9 @@ export const aiApi = { if (res.status === 401) { clearToken(); useUserStore.getState().logout(); - throw new Error('登录已过期,请重新登录'); + throw new Error(i18n.t('common.requestts.sd3ab821c')); } - if (!res.body) throw new Error('流式响应不可用'); + if (!res.body) throw new Error(i18n.t('aiops.assistantts.s16f94bee')); const reader = res.body.getReader(); const decoder = new TextDecoder('utf-8'); let buffer = ''; @@ -102,10 +103,10 @@ export const aiApi = { // {code, message} try { const obj = JSON.parse(data); - throw new Error(obj.message || 'LLM 流式响应错误'); + throw new Error(obj.message || i18n.t('aiops.assistantts.sfeeaa489')); } catch (parseErr) { if (parseErr instanceof Error && parseErr.message) throw parseErr; - throw new Error('LLM 流式响应错误'); + throw new Error(i18n.t('aiops.assistantts.sfeeaa489')); } } if (eventType === 'done') { diff --git a/frontend/src/components/agent/AgentAlerts.tsx b/frontend/src/components/agent/AgentAlerts.tsx index 7a802ff..57bf8c1 100644 --- a/frontend/src/components/agent/AgentAlerts.tsx +++ b/frontend/src/components/agent/AgentAlerts.tsx @@ -28,6 +28,7 @@ import { } from './agentAlertHelper'; import { AgentRuleDialog } from './AgentRuleDialog'; import type { JsonData } from '@/types/common'; +import i18n from '@/i18n'; export function AgentAlerts() { const confirm = useConfirm(); @@ -52,7 +53,7 @@ export function AgentAlerts() { setRules(asList(rulesRes)); } catch (err) { console.error(err); - toast.error('加载告警数据失败'); + toast.error(i18n.t('agent.agentalertstsx.s7ffaa448')); } finally { setLoading(false); } @@ -64,14 +65,14 @@ export function AgentAlerts() { // ============ 告警事件 ============ const handleResolve = async (id: number) => { - const ok = await confirm({ title: '恢复告警', description: '确定将此告警标记为已恢复?', confirmText: '恢复' }); + const ok = await confirm({ title: i18n.t('agent.agentalertstsx.sd56d01fa'), description: i18n.t('agent.agentalertstsx.s99f0fb65'), confirmText: i18n.t('kubernetes.deployment.resume') }); if (!ok) return; try { await agentApi.resolveAlert(id); - toast.success('告警已恢复'); + toast.success(i18n.t('agent.agentalertstsx.s0e23522e')); loadData(); } catch (err) { - toast.error(err?.message || '操作失败'); + toast.error(err?.message || i18n.t('cloud.operationFailed')); } }; @@ -87,14 +88,14 @@ export function AgentAlerts() { }; const handleDeleteRule = async (id: number) => { - const ok = await confirm({ title: '删除规则', description: '确定删除此告警规则?', confirmText: '删除', variant: 'destructive' }); + const ok = await confirm({ title: i18n.t('monitor.deleteRule'), description: i18n.t('monitor.alertrulestabts.sd301558d'), confirmText: i18n.t('kubernetes.storage.delete2'), variant: 'destructive' }); if (!ok) return; try { await agentApi.deleteRule(id); - toast.success('规则已删除'); + toast.success(i18n.t('agent.agentalertstsx.s8b2798c4')); loadData(); } catch (err) { - toast.error(err?.message || '删除失败'); + toast.error(err?.message || i18n.t('kubernetes.msg.deleteFailed2')); } }; @@ -103,7 +104,7 @@ export function AgentAlerts() { await agentApi.updateRule(rule.id, { ...rule, enabled: !rule.enabled }); loadData(); } catch (err) { - toast.error(err?.message || '操作失败'); + toast.error(err?.message || i18n.t('cloud.operationFailed')); } }; @@ -113,7 +114,7 @@ export function AgentAlerts() {

Agent 告警

-

基于 Agent 上报指标的告警规则与事件

+

{i18n.t('agent.agentalertstsx.s03a08cd6')}

diff --git a/frontend/src/components/agent/AgentMonitor.tsx b/frontend/src/components/agent/AgentMonitor.tsx index 34c2975..6d6af88 100644 --- a/frontend/src/components/agent/AgentMonitor.tsx +++ b/frontend/src/components/agent/AgentMonitor.tsx @@ -13,6 +13,7 @@ import { Label } from '@/components/ui/label'; import { Textarea } from '@/components/ui/textarea'; import { Badge } from '@/components/ui/badge'; import { Progress } from '@/components/ui/progress'; +import i18n from '@/i18n'; import { Dialog, DialogContent, @@ -68,7 +69,7 @@ export function AgentMonitor() { if (fresh) setSelectedHost(fresh); } } catch (err) { - if (!silent) toast.error('加载主机列表失败'); + if (!silent) toast.error(i18n.t('agent.agentmonitortsx.s5760f667')); console.error(err); } finally { setLoading(false); @@ -97,7 +98,7 @@ export function AgentMonitor() { // 提交远程命令(直连 SSH 即时返回) const submitCommand = async () => { if (!cmdCommand.trim()) { - toast.error('请输入要执行的命令'); + toast.error(i18n.t('agent.agentmonitortsx.s9358aada')); return; } setCmdSubmitting(true); @@ -111,11 +112,11 @@ export function AgentMonitor() { const resData = (res?.data ?? {}) as Record; 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) || i18n.t('agent.agentmonitortsx.s26d45bea'), error: resData.error as string | undefined, }); } catch (err) { - setCmdResult({ status: 'failed', result: err?.message || '执行失败' }); + setCmdResult({ status: 'failed', result: err?.message || i18n.t('automation.systemTaskFailed') }); } finally { setCmdSubmitting(false); loadLatest(true); @@ -129,9 +130,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: i18n.t('monitor.hostDashboard.hostTotal'), value: hosts.length, icon: Server, color: 'dg-text-blue' }, + { label: i18n.t('agent.agentOnline'), value: onlineCount, icon: Wifi, color: 'dg-text-green' }, + { label: i18n.t('agent.agentOffline'), value: hosts.length - onlineCount, icon: WifiOff, color: 'dg-text-red' }, ]; return ( @@ -140,7 +141,7 @@ export function AgentMonitor() {

Agent 监控

-

实时监控 Agent 上报的主机指标

+

{i18n.t('agent.agentmonitortsx.sa75d7519')}