diff --git a/web/frontend/src/pages/agents-management/index.jsx b/web/frontend/src/pages/agents-management/index.jsx index 7619cb605..8460e8918 100644 --- a/web/frontend/src/pages/agents-management/index.jsx +++ b/web/frontend/src/pages/agents-management/index.jsx @@ -30,7 +30,7 @@ export default function AgentsManagementPage() { try { setDetail(await api.get(`/multi-agent/markdown-agents/${encodeURIComponent(record.filename)}`)); } catch (error) { - toastError(error, '读取智能体失败'); + toastError(error, t('agents.loadFailed')); } }; @@ -46,43 +46,43 @@ export default function AgentsManagementPage() { kind: values.kind || 'sub', tools: String(values.tools || '').split(',').map(item => item.trim()).filter(Boolean) }); - toastSuccess('智能体已保存'); + toastSuccess(t('agents.saved')); setEditor(null); agents.reload(); } catch (error) { - toastError(error, '保存智能体失败'); + toastError(error, t('agents.saveFailed')); } finally { setSaving(false); } }; const remove = row => confirmAction({ - title: `删除智能体「${row.name || row.filename}」?`, + title: t('agents.confirmDelete', { name: row.name || row.filename }), onOk: async () => { await api.del(`/multi-agent/markdown-agents/${encodeURIComponent(row.filename)}`); - toastSuccess('已删除'); + toastSuccess(t('agents.deleted')); agents.reload(); } }); const columns = [ { - title: '智能体', dataIndex: 'name', render: (value, record) => ( + title: t('agents.agent'), dataIndex: 'name', render: (value, record) => ( {value || record.id} - {record.is_orchestrator && 编排器} + {record.is_orchestrator && {t('agents.orchestrator')}} {record.filename} ) }, - { title: '类型', dataIndex: 'kind', width: 110, render: value => {value || 'sub'} }, - { title: '描述', dataIndex: 'description', render: value => {value || '—'} }, + { title: t('agents.kind'), dataIndex: 'kind', width: 110, render: value => {value || 'sub'} }, + { title: t('agents.description'), dataIndex: 'description', render: value => {value || '—'} }, { - title: '操作', width: 180, render: (_, record) => ( + title: t('agents.actions'), width: 180, render: (_, record) => ( - + {canWrite && - {canWrite && } + + {canWrite && } )} /> {agents.data?.error && } - + agents.reload()} /> } value={search} onChange={setSearch} placeholder="搜索名称或文件名" style={{ width: 280 }} />} + toolbar={} value={search} onChange={setSearch} placeholder={t('agents.searchPlaceholder')} style={{ width: 280 }} />} /> setEditor(null)} @@ -133,32 +133,32 @@ export default function AgentsManagementPage() { kind: editor.record.kind || 'sub' } : { kind: 'sub' }} > - - - - + + + - - + + - setDetail(null)} width={720}> + setDetail(null)} width={720}> {detail && (
- +
)}
diff --git a/web/frontend/src/pages/dashboard/index.jsx b/web/frontend/src/pages/dashboard/index.jsx index 79fc04dcb..f3f825fab 100644 --- a/web/frontend/src/pages/dashboard/index.jsx +++ b/web/frontend/src/pages/dashboard/index.jsx @@ -75,30 +75,32 @@ function countList(value, ...keys) { } function DashboardEmpty({ loading, unavailable, title, description }) { + const t = useT(); return ( ); } function RecentVulnerabilities({ data, loading, onOpen }) { + const t = useT(); const list = getList(data, 'vulnerabilities'); return ( } + emptyContent={} renderItem={item => ( {item.host || item.target || '—'} · {formatDateTime(item.created_at)} @@ -113,6 +115,7 @@ function RecentVulnerabilities({ data, loading, onOpen }) { } function RecentFacts({ summary, loading, onOpen }) { + const t = useT(); const facts = getList(summary, 'recent_facts', 'facts'); return ( } + emptyContent={} renderItem={(fact, index) => ( - {fact.title || fact.summary || fact.key || fact.fact_key || fact.subject || '事实'} + {fact.title || fact.summary || fact.key || fact.fact_key || fact.subject || t('dashboard.fact')} {fact.project_name || fact.projectName || fact.value || '—'} @@ -136,7 +139,7 @@ function RecentFacts({ summary, loading, onOpen }) { {fact.status && {fact.status}} {fact.project_id && ( - - + + } /> @@ -260,10 +263,10 @@ export default function DashboardPage() { type="info" fullMode={false} closeIcon={null} - title={data.unavailableCount === data.sourceCount ? '数据暂不可用' : '部分数据不可用'} + title={data.unavailableCount === data.sourceCount ? t('dashboard.dataUnavailable') : t('dashboard.partialDataUnavailable')} description={data.unavailableCount === data.sourceCount - ? '本次未能取得仪表盘数据,请检查服务连接后刷新重试。' - : `${data.unavailableCount} 项数据源未能加载,相关数值以 — 显示。已返回的数据仍可查看,请稍后刷新重试。`} + ? t('dashboard.allSourcesFailed') + : t('dashboard.someSourcesFailed', { count: data.unavailableCount })} /> )} {alerts.length > 0 && ( @@ -274,7 +277,7 @@ export default function DashboardPage() { closeIcon={null} description={( - 需要关注 + {t('dashboard.needsAttention')} {alerts.map(item => ( } + title={t('dashboard.recentVulns')} + extra={} > navigate(`/vulnerabilities?id=${encodeURIComponent(id)}`)} />
} iconPosition="right" onClick={() => navigate('/projects')}>全部项目} + title={t('dashboard.projects')} + extra={} > navigate('/mcp-monitor')}>调用监控} + title={t('dashboard.toolsTop')} + extra={} >
- + @@ -343,9 +346,10 @@ export default function DashboardPage() { } function TopTools({ data, loading }) { + const t = useT(); const tools = getList(data, 'topTools'); const items = tools?.slice(0, 8).map(tool => ({ - name: tool.name || tool.toolName || '未命名工具', + name: tool.name || tool.toolName || t('dashboard.unnamedTool'), count: asCount(tool.count ?? tool.calls ?? tool.totalCalls) })) || []; const max = Math.max(...items.map(tool => tool.count ?? 0), 1); @@ -354,17 +358,17 @@ function TopTools({ data, loading }) { className="dashboard-list" loading={loading} dataSource={items} - emptyContent={} + emptyContent={} renderItem={(tool, index) => ( {index + 1}
{tool.name} - {displayCount(tool.count)} 次 + {t('dashboard.callsUnit', { count: displayCount(tool.count) })}
{tool.count !== null && ( - + )}
@@ -374,13 +378,14 @@ function TopTools({ data, loading }) { } function ProjectSummary({ summary, loading, onOpen }) { + const t = useT(); const projects = getList(summary, 'projects'); const facts = getList(summary, 'recent_facts', 'facts'); const totalsSource = summary?.totals || summary; const totals = [ - ['活跃项目', totalsSource?.active_projects ?? totalsSource?.activeProjects], - ['事实总数', totalsSource?.total_facts ?? totalsSource?.totalFacts], - ['最近事实', facts?.length] + [t('dashboard.activeProjects'), totalsSource?.active_projects ?? totalsSource?.activeProjects], + [t('dashboard.totalFacts'), totalsSource?.total_facts ?? totalsSource?.totalFacts], + [t('dashboard.recentFactsCount'), facts?.length] ]; return (
@@ -400,8 +405,8 @@ function ProjectSummary({ summary, loading, onOpen }) { )} renderItem={project => ( @@ -409,7 +414,7 @@ function ProjectSummary({ summary, loading, onOpen }) { key={project.id} main={(
- + {project.status || '—'} · {formatDateTime(project.updated_at)} diff --git a/web/frontend/src/pages/dashboard/vulnerability-overview.jsx b/web/frontend/src/pages/dashboard/vulnerability-overview.jsx index 2bd2182cc..f13cd2816 100644 --- a/web/frontend/src/pages/dashboard/vulnerability-overview.jsx +++ b/web/frontend/src/pages/dashboard/vulnerability-overview.jsx @@ -8,26 +8,22 @@ import { formatNumber, relativeTime, SEVERITY_ORDER } from '../../lib/format'; import { useT } from '../../lib/i18n'; import { api } from '../../lib/http'; -const SEVERITY_NAMES = ['严重', '高危', '中危', '低危', '信息']; +const SEVERITY_KEYS = ['dashboard.severityCritical', 'dashboard.severityHigh', 'dashboard.severityMedium', 'dashboard.severityLow', 'dashboard.severityInfo']; const RISK_LEVELS = [ - [0, 'safe', 'Safe', '安全'], - [3, 'low', 'Low', '低'], - [10, 'medium', 'Medium', '中'], - [30, 'high', 'High', '高'], - [Infinity, 'severe', 'Severe', '极高'] + [0, 'safe', 'dashboard.riskSafe'], + [3, 'low', 'dashboard.riskLow'], + [10, 'medium', 'dashboard.riskMedium'], + [30, 'high', 'dashboard.riskHigh'], + [Infinity, 'severe', 'dashboard.riskSevere'] ]; const STATUSES = [ - ['open', 'Open', '待处理'], - ['confirmed', 'Confirmed', '已确认'], - ['fixed', 'Fixed', '已修复'], - ['ignored', 'Ignored', '已忽略'], - ['false_positive', 'FalsePositive', '误报'] + ['open', 'Open'], + ['confirmed', 'Confirmed'], + ['fixed', 'Fixed'], + ['ignored', 'Ignored'], + ['false_positive', 'FalsePositive'] ]; -function capitalized(key) { - return key[0].toUpperCase() + key.slice(1); -} - export function asCount(value) { if (value == null || value === '' || !['number', 'string'].includes(typeof value)) return null; const number = Number(value); @@ -90,7 +86,7 @@ function SeverityChart({ rows, total, status, loading, t }) { return <>
- + {rows.map(row => ( @@ -113,7 +109,7 @@ function SeverityChart({ rows, total, status, loading, t }) {
{displayTotal} - {selected?.label || t('dashboard.totalVulns', null, '总漏洞数')} + {selected?.label || t('dashboard.totalVulns')}
@@ -136,36 +132,36 @@ function RiskSummary({ stats, latest, t }) { const score = counts.some(value => value === null) ? null : counts[0] * 10 + counts[1] * 5 + counts[2] * 2 + counts[3] * .5; - const [, tone, label, fallback] = score === null - ? [null, 'unknown', '', ''] + const [, tone, labelKey] = score === null + ? [null, 'unknown', ''] : RISK_LEVELS.find(([max]) => score <= max); return ( -
- {t('dashboard.fixRate', null, '修复率')} + {t('dashboard.fixRate')} {rate === null ? '—' : `${rate.toFixed(rate === 100 ? 0 : 1)}%`} {counts && ({formatNumber(fixed)} / {formatNumber(actionable)})} @@ -210,7 +206,7 @@ function Resolution({ counts, states, t }) { export default function VulnerabilityOverview({ stats, pendingStats, latest, loadedAt, loading }) { const t = useT(); const [params, setParams] = useSearchParams(); - const states = STATUSES.map(([value, key, fallback]) => ({ value, label: t('dashboard.status' + key, null, fallback) })); + const states = STATUSES.map(([value, key]) => ({ value, label: t('dashboard.status' + key) })); const requested = params.get('risk_status'); const status = states.some(state => state.value === requested) ? requested : ''; const needsQuery = Boolean(status && status !== 'open'); @@ -234,20 +230,20 @@ export default function VulnerabilityOverview({ stats, pendingStats, latest, loa : Math.max(asCount(distribution?.total) ?? 0, counts.reduce((sum, count) => sum + count, 0)); const rows = SEVERITY_ORDER.map((key, index) => ({ key, - label: t('dashboard.severity' + capitalized(key), null, SEVERITY_NAMES[index]), + label: t(SEVERITY_KEYS[index]), count: counts[index], percent: total === null ? null : total === 0 ? 0 : Math.round(counts[index] / total * 100) })); return ( } value={keyword} onChange={value => { setKeyword(value); setPage(1); }} placeholder="搜索标题或内容" style={{ width: 220 }} /> + } value={keyword} onChange={value => { setKeyword(value); setPage(1); }} placeholder={t('knowledge.searchPlaceholder')} style={{ width: 220 }} /> { setQuery(value); setOffset(0); }} /> + + { setQuery(value); setOffset(0); }} /> - + - + {offset + resources.length} / {data?.total ?? '—'} - + {nameError && {nameError}} - {isDefaultRole && 默认角色名称不可修改。} + {isDefaultRole && {t('roles.defaultNameHint')}}
- +
- +
- +