feat(i18n): U46 残余UI硬编码中文清零 — 6文件12处→0 (UserFormDialog/CredentialManager/RdpAuditViewer/LiveMonitorDialog/ServerFileBrowser/context-loaders) +17翻译键 zh/en 8085→8102对齐

This commit is contained in:
attacker committed 2026-07-16 02:29:47 +08:00
1 parent 6288fa0071
commit 21728be445
10 files changed
+118 -25

No files matched your search

+1
View File
@@ -533,6 +533,7 @@ services/api.ts (1324L)
| U44 | i18n 残余硬编码中文清零 — 终端审计状态 + 凭证类型 + 流水线阶段 + 时间格式 + CSV 导出(20 文件 ~70 处→0: credential-manager/constants.ts 8 凭证类型 label/desc → labelKey/descKey + i18n.t() + pipeline-run-detail/types.ts 6 阶段 label → i18n.t('deploy.stage.*') + labelKey + pipeline-manager/constants.ts + pipeline-editor/types.ts 分秒 duration → i18n.t('common.duration.minSec') + LiveMonitorDialog 6 终端状态消息 → t() + RdpAuditViewer 6 RDP审计状态 → i18n.t('monitor.rdp.*') + WorkspaceTermDialog 2 终端连接状态 → t() + TerminalSessionsTab 4 时长格式+状态标签 → i18n.t()/t() + k8s-event-utils 3 相对时间 → i18n.t('common.duration.*Ago') + QueryHistoryPanel 3 相对时间 → i18n.t('common.duration.*Ago') + export-audit.ts 9 CSV导出表头 → i18n.t('system.auditExport.*') + useAuditSettings 4 审计保留策略消息 → i18n.t('system.auditSettings.*') + event-handler.ts 4 AgentCLI事件消息 → i18n.t('aiops.cli.*') + NotifyPolicyTab 默认平台名 → i18n.t('monitor.notify.defaultPlatform') + RoleFormDialog AIOps智能分组 → i18n.t('system.role.aiopsGroup') + CronJobViewDialog 关联脚本/无命令内容 → t() + TerminalOutput 无输出 → i18n.t('task.terminal.noOutput') + shared-components 内存标签 → i18n.t('k8s.workloadView.memoryLabel') + prometheus-ds/helpers 连接成功 → i18n.t('monitor.prometheus.connSuccess') + CloudServerImport 发现主机失败 → t() + AdvancedSettingsPanel Job名称 → t('deploy.jobName') + releaseManagerHelpers 4 环境标签硬编码中文移除(已有ENV_LABEL_KEY) — 新增 75 翻译键 (deploy.credType 8+credTypeDesc 8+fmtDuration 1+terminal 2+jobName 1, monitor.terminal 6+rdp 6+notify 1+prometheus 1, deploy.terminal 2, common.duration 2, system.terminalSession 4+csvHeader 7+auditExport 9+auditSettings 4+credTypeLabel 3+role 1, task.cronJob 2+terminal 1, k8s.workloadView 1, aiops.cli 5, server.import 1), zh/en 7987→8059 +72 对齐;tsc -b=0, npm build✓ (17.13s), ESLint=0/43/any=0, go build=0, 17/17 测试通过) | P3 | **done** | | U44 | i18n 残余硬编码中文清零 — 终端审计状态 + 凭证类型 + 流水线阶段 + 时间格式 + CSV 导出(20 文件 ~70 处→0: credential-manager/constants.ts 8 凭证类型 label/desc → labelKey/descKey + i18n.t() + pipeline-run-detail/types.ts 6 阶段 label → i18n.t('deploy.stage.*') + labelKey + pipeline-manager/constants.ts + pipeline-editor/types.ts 分秒 duration → i18n.t('common.duration.minSec') + LiveMonitorDialog 6 终端状态消息 → t() + RdpAuditViewer 6 RDP审计状态 → i18n.t('monitor.rdp.*') + WorkspaceTermDialog 2 终端连接状态 → t() + TerminalSessionsTab 4 时长格式+状态标签 → i18n.t()/t() + k8s-event-utils 3 相对时间 → i18n.t('common.duration.*Ago') + QueryHistoryPanel 3 相对时间 → i18n.t('common.duration.*Ago') + export-audit.ts 9 CSV导出表头 → i18n.t('system.auditExport.*') + useAuditSettings 4 审计保留策略消息 → i18n.t('system.auditSettings.*') + event-handler.ts 4 AgentCLI事件消息 → i18n.t('aiops.cli.*') + NotifyPolicyTab 默认平台名 → i18n.t('monitor.notify.defaultPlatform') + RoleFormDialog AIOps智能分组 → i18n.t('system.role.aiopsGroup') + CronJobViewDialog 关联脚本/无命令内容 → t() + TerminalOutput 无输出 → i18n.t('task.terminal.noOutput') + shared-components 内存标签 → i18n.t('k8s.workloadView.memoryLabel') + prometheus-ds/helpers 连接成功 → i18n.t('monitor.prometheus.connSuccess') + CloudServerImport 发现主机失败 → t() + AdvancedSettingsPanel Job名称 → t('deploy.jobName') + releaseManagerHelpers 4 环境标签硬编码中文移除(已有ENV_LABEL_KEY) — 新增 75 翻译键 (deploy.credType 8+credTypeDesc 8+fmtDuration 1+terminal 2+jobName 1, monitor.terminal 6+rdp 6+notify 1+prometheus 1, deploy.terminal 2, common.duration 2, system.terminalSession 4+csvHeader 7+auditExport 9+auditSettings 4+credTypeLabel 3+role 1, task.cronJob 2+terminal 1, k8s.workloadView 1, aiops.cli 5, server.import 1), zh/en 7987→8059 +72 对齐;tsc -b=0, npm build✓ (17.13s), ESLint=0/43/any=0, go build=0, 17/17 测试通过) | P3 | **done** |
| U42 | i18n 残余硬编码中文彻底清零 — 全量 JSX children + toast/confirm + sr-only 描述(33 文件 54 处→0: PredictiveCapacityTab AI深度解读/紧急/警告/7天使用率预测/预计N天/后达到阈值/AI建议 + PredictiveCostTab AI深度解读 + event-handler.ts 高危操作确认 toast + DeployCredentials 启用/禁用 + DeployRBAC 删除角色 confirm + WorkspaceTermDialog 标题 + CredFormDialog Windows用户 + ClusterOverviewPage 核 + DeploymentEditContainers Pod级别 + DeploymentEditService 无selector/个关联/Ingresses应用路由/暂无Service/暂无Ingress/自动高亮 + DeploymentEditStorage 无容器 + KubectlTerminal sr-only + KubernetesClusterDialog 已配置 + ResourceVisualEditor YAML编辑 + CreateHPADialog CPU目标 + UpdateStrategyCard maxSurge/maxUnavailable/revisionHistoryLimit/progressDeadlineSeconds 说明 + IngressCreateForm host域名/Service端口 + ServiceCreateForm 端口配置/个端口/selector自动检测 + PodInstancesTable Pod名称 + UpdateStrategySelectorCards Pod管理策略 + AlertRulesTab 删除confirm/分钟 + PrometheusDatasourceManager 删除confirm + LogDatasourcePage 删除confirm + QueryHistoryPanel 条 + ServerFileBrowser sr-only + TerminalDialog sr-only + CredentialManager 删除confirm + RdpAuditViewer sr-only + SystemManager 删除用户/批量删除 confirm + TerminalSessionsTab 删除confirm + SecuritySettingsTab 30分钟/2小时 + CronJobViewDialog 次 — 新增 k8s.editAdvanced 6键+k8s.editService 11键+k8s.cluster 2键+k8s.clusterDialog 1键+k8s.kubectlTerminalDesc/k8s.rve.yamlEditBtn/k8s.hpa.cpuTarget/k8s.podLevel/k8s.podNameLabel/k8s.podManagePolicy 共 28键 + aiops.capacity 8键+aiops.cost 1键+aiops.cli 2键 + deploy.cred.windowsUser/deploy.workspaceTerminalTitle/deploy.rbac.deleteRoleDesc/deploy.cred.badgeDefault 4键 + monitor.deleteRulesConfirmDesc/deleteDatasourceConfirmDesc/deleteLogDsConfirmDesc/durationMinutes/queryHistory.count 5键 + system.rdpLiveAudit/rdpHistoryReplay/rdpAuditDesc/sshTerminalDesc/sftpFileDesc/sftpFileLabel/deleteUserConfirmDesc/batchDeleteUsersConfirmDesc/deleteCredConfirmDesc/deleteTermSessionsConfirmDesc 10键 + task.cronJob.runCount 1键 + common.minutes30/hours2 2键, zh/en 7847→7898 对齐;tsc -b=0, npm build✓ (17.71s), ESLint=0/43/any=0, go build=0, 17/17 测试通过) | P3 | **done** | | U42 | i18n 残余硬编码中文彻底清零 — 全量 JSX children + toast/confirm + sr-only 描述(33 文件 54 处→0: PredictiveCapacityTab AI深度解读/紧急/警告/7天使用率预测/预计N天/后达到阈值/AI建议 + PredictiveCostTab AI深度解读 + event-handler.ts 高危操作确认 toast + DeployCredentials 启用/禁用 + DeployRBAC 删除角色 confirm + WorkspaceTermDialog 标题 + CredFormDialog Windows用户 + ClusterOverviewPage 核 + DeploymentEditContainers Pod级别 + DeploymentEditService 无selector/个关联/Ingresses应用路由/暂无Service/暂无Ingress/自动高亮 + DeploymentEditStorage 无容器 + KubectlTerminal sr-only + KubernetesClusterDialog 已配置 + ResourceVisualEditor YAML编辑 + CreateHPADialog CPU目标 + UpdateStrategyCard maxSurge/maxUnavailable/revisionHistoryLimit/progressDeadlineSeconds 说明 + IngressCreateForm host域名/Service端口 + ServiceCreateForm 端口配置/个端口/selector自动检测 + PodInstancesTable Pod名称 + UpdateStrategySelectorCards Pod管理策略 + AlertRulesTab 删除confirm/分钟 + PrometheusDatasourceManager 删除confirm + LogDatasourcePage 删除confirm + QueryHistoryPanel 条 + ServerFileBrowser sr-only + TerminalDialog sr-only + CredentialManager 删除confirm + RdpAuditViewer sr-only + SystemManager 删除用户/批量删除 confirm + TerminalSessionsTab 删除confirm + SecuritySettingsTab 30分钟/2小时 + CronJobViewDialog 次 — 新增 k8s.editAdvanced 6键+k8s.editService 11键+k8s.cluster 2键+k8s.clusterDialog 1键+k8s.kubectlTerminalDesc/k8s.rve.yamlEditBtn/k8s.hpa.cpuTarget/k8s.podLevel/k8s.podNameLabel/k8s.podManagePolicy 共 28键 + aiops.capacity 8键+aiops.cost 1键+aiops.cli 2键 + deploy.cred.windowsUser/deploy.workspaceTerminalTitle/deploy.rbac.deleteRoleDesc/deploy.cred.badgeDefault 4键 + monitor.deleteRulesConfirmDesc/deleteDatasourceConfirmDesc/deleteLogDsConfirmDesc/durationMinutes/queryHistory.count 5键 + system.rdpLiveAudit/rdpHistoryReplay/rdpAuditDesc/sshTerminalDesc/sftpFileDesc/sftpFileLabel/deleteUserConfirmDesc/batchDeleteUsersConfirmDesc/deleteCredConfirmDesc/deleteTermSessionsConfirmDesc 10键 + task.cronJob.runCount 1键 + common.minutes30/hours2 2键, zh/en 7847→7898 对齐;tsc -b=0, npm build✓ (17.71s), ESLint=0/43/any=0, go build=0, 17/17 测试通过) | P3 | **done** |
| U45 | AI 告警分析模块 i18n 补全(analyzerHelpers.ts 6 告警类型 × ~4 模板字符串 = 25 处硬编码中文 rootCause/impact/recommendations→i18n.t() 插值 + mapAlertEvent locale 硬编码 zh-CN→动态 i18n.language + 事件ID比较硬编码→i18n.t(defaultEvent) + AIPredictiveAnalytics 预测图标中文-only includes→match() 双语兼容 — 新增 aiops.analyzer 26 翻译键, zh/en 8059→8085 对齐;tsc -b=0, npm build✓ (17.40s), ESLint=0/43/any=0, go build=0, 17/17 测试通过) | P3 | **done** | | U45 | AI 告警分析模块 i18n 补全(analyzerHelpers.ts 6 告警类型 × ~4 模板字符串 = 25 处硬编码中文 rootCause/impact/recommendations→i18n.t() 插值 + mapAlertEvent locale 硬编码 zh-CN→动态 i18n.language + 事件ID比较硬编码→i18n.t(defaultEvent) + AIPredictiveAnalytics 预测图标中文-only includes→match() 双语兼容 — 新增 aiops.analyzer 26 翻译键, zh/en 8059→8085 对齐;tsc -b=0, npm build✓ (17.40s), ESLint=0/43/any=0, go build=0, 17/17 测试通过) | P3 | **done** |
| U46 | i18n 残余 UI 硬编码中文清零 — 深度边角(6 文件 12 处→0: UserFormDialog '新建用户' + CredentialManager '显示' title + RdpAuditViewer RDP实时审计/RDP历史回放/录屏帧解码失败 + LiveMonitorDialog 连接超时提示 + ServerFileBrowser prompt输入目录名 + context-loaders.ts AI上下文模板字符串(alertSummary/alertLine/metricLine/highLoadHosts/agentMetricsSummary/platformOverview/highLoadAssets/recentAlerts/recentReleases/overviewFallback) 全量 i18n.t() 插值 — 新增 common.show/dirNamePrompt + system.createUser/rdpFrameError/rdpHistoryReplayId/connectTimeoutActive + aiops.ctx 11 键 共 17 翻译键, zh/en 8085→8102 对齐;tsc -b=0, npm build✓ (18.05s), ESLint=0/43/any=0, go build=0, 17/17 测试通过) | P3 | **done** |
| U37 | 全量 JSX 文本节点硬编码中文清零(65 文件 151 处→0: MiddlewareMonitor/SiteMonitor/SNMPMonitor/HealthProbeSection/ContextSwitchCard/ProcessTable/PortMonitorTab/MwTargetChartsPanel/MiddlewareDialog/ChartRangeHint/SnmpDeviceChartsPanel/AlertRulesTab/LogClusterPanel/LogDatasourcePage/LogQueryToolbar/LogAlertsPanel/PrometheusDatasourceManager/PodMetricsPage/CapacityPage/NamespaceManagementPage/NamespaceResourcePage/DeploymentEditService/EventsPage/DeploymentDetail/ClusterOverviewPage/DeploymentEditContainers/DeploymentEditStorage/WorkloadViewPage/BottomStatusBar/UpdateStrategySelectorCards/PodInstancesTable/shared-components/UpdateStrategyCard/TolerationsCard/HostSettingsCard/IngressListItem/ServiceListItem/ServiceCreateForm/IngressCreateForm/CreateHPADialog/DeployCredentials/DeployRBAC/UserGroupsManager/BuildNodesManager/DeployTargetFields/PipelineCreateDialog/CredFormDialog/WorkspaceTermDialog/AgentAlerts/AgentRuleDialog/LiveMonitorDialog/RoleFormDialog/CronJobViewDialog/TerminalOutput/AIAnalysisResult/AIPredictiveAnalytics/PredictiveCostTab/PredictiveCapacityTab/ActiveSessionsPanel/HistorySessionsPanel/TerminalDialog/ServerFileBrowser/PodFileBrowser/SiteResultsPanel/SiteProtocolPieChart — 151 JSX 文本节点中文全部替换为 t()/i18n.t() 调用;新增 common.* 98 翻译键 (selectedCount/itemsCount/newValue/namespaceLabel/containerLabel/replicasLabel/minReplicas/maxReplicas/createNamespace/noNamespace/unknownResource/exportYaml/loadTrend/loadCapacity/predicted/threshold/hostSettings/addVolume/addMount/createService/createIngress/editAction/updateStrategy/selectAndLabel/historyVersion/fileBrowser/scale/back/createHpa/allNamespaces/certLabel/observable/deviceList/addDevice/addMonitor/collectNow/addTask/addProbe/restoreFull/contextSwitch/processTop/listenPorts/terminalRealtime/auditWebssh/buildTerminal/fileBrowse/newDir/loadDeployment/notLinked/selectedPerms/none/hasLabel/deleteNamespace/deleteNamespaceWarn/allResources/notFoundDeploy/nodeList/fileLabel/addCustom/newInstanceService/newInstanceIngress/totalContainers/workContainers/loadingEllipsis/volumeClaimTemplates/containerTemplate/passwordOptional/updated/page/perPage/clusterMode/totalLogs/countLabel/percentage/queryTime/addDatasource/newPermission/newEnv/envLabel/displayName/newUserGroup/auditTrace/predictValue/confidence/predictMonthEnd/noCapacityData/securityMode/standardRdp/domainLabel/noRdpActive/noRdpHistory/buffer/matched/podLogs/createHpaTitle/password/events/total);37 文件已有 import i18n→i18n.t() 模式, 2 文件新增 import i18n;zh/en 7640→3526 namespace-flat +98 键对齐;tsc -b=0, npm build✓ (17.96s), ESLint=0/43/any=0, go build=0, 17/17 测试通过) | P3 | **done** | | U37 | 全量 JSX 文本节点硬编码中文清零(65 文件 151 处→0: MiddlewareMonitor/SiteMonitor/SNMPMonitor/HealthProbeSection/ContextSwitchCard/ProcessTable/PortMonitorTab/MwTargetChartsPanel/MiddlewareDialog/ChartRangeHint/SnmpDeviceChartsPanel/AlertRulesTab/LogClusterPanel/LogDatasourcePage/LogQueryToolbar/LogAlertsPanel/PrometheusDatasourceManager/PodMetricsPage/CapacityPage/NamespaceManagementPage/NamespaceResourcePage/DeploymentEditService/EventsPage/DeploymentDetail/ClusterOverviewPage/DeploymentEditContainers/DeploymentEditStorage/WorkloadViewPage/BottomStatusBar/UpdateStrategySelectorCards/PodInstancesTable/shared-components/UpdateStrategyCard/TolerationsCard/HostSettingsCard/IngressListItem/ServiceListItem/ServiceCreateForm/IngressCreateForm/CreateHPADialog/DeployCredentials/DeployRBAC/UserGroupsManager/BuildNodesManager/DeployTargetFields/PipelineCreateDialog/CredFormDialog/WorkspaceTermDialog/AgentAlerts/AgentRuleDialog/LiveMonitorDialog/RoleFormDialog/CronJobViewDialog/TerminalOutput/AIAnalysisResult/AIPredictiveAnalytics/PredictiveCostTab/PredictiveCapacityTab/ActiveSessionsPanel/HistorySessionsPanel/TerminalDialog/ServerFileBrowser/PodFileBrowser/SiteResultsPanel/SiteProtocolPieChart — 151 JSX 文本节点中文全部替换为 t()/i18n.t() 调用;新增 common.* 98 翻译键 (selectedCount/itemsCount/newValue/namespaceLabel/containerLabel/replicasLabel/minReplicas/maxReplicas/createNamespace/noNamespace/unknownResource/exportYaml/loadTrend/loadCapacity/predicted/threshold/hostSettings/addVolume/addMount/createService/createIngress/editAction/updateStrategy/selectAndLabel/historyVersion/fileBrowser/scale/back/createHpa/allNamespaces/certLabel/observable/deviceList/addDevice/addMonitor/collectNow/addTask/addProbe/restoreFull/contextSwitch/processTop/listenPorts/terminalRealtime/auditWebssh/buildTerminal/fileBrowse/newDir/loadDeployment/notLinked/selectedPerms/none/hasLabel/deleteNamespace/deleteNamespaceWarn/allResources/notFoundDeploy/nodeList/fileLabel/addCustom/newInstanceService/newInstanceIngress/totalContainers/workContainers/loadingEllipsis/volumeClaimTemplates/containerTemplate/passwordOptional/updated/page/perPage/clusterMode/totalLogs/countLabel/percentage/queryTime/addDatasource/newPermission/newEnv/envLabel/displayName/newUserGroup/auditTrace/predictValue/confidence/predictMonthEnd/noCapacityData/securityMode/standardRdp/domainLabel/noRdpActive/noRdpHistory/buffer/matched/podLogs/createHpaTitle/password/events/total);37 文件已有 import i18n→i18n.t() 模式, 2 文件新增 import i18n;zh/en 7640→3526 namespace-flat +98 键对齐;tsc -b=0, npm build✓ (17.96s), ESLint=0/43/any=0, go build=0, 17/17 测试通过) | P3 | **done** |
--- ---
+15
View File
@@ -1519,3 +1519,18 @@ curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer ${TOKEN}" "http
- [x] 17/17 集成回归测试通过(零回归) - [x] 17/17 集成回归测试通过(零回归)
- [x] Docker 部署 healthy - [x] Docker 部署 healthy
---
## U46: i18n 残余 UI 硬编码中文清零 — 深度边角
### 通过标准
- [x] 6 个修复文件中无残余硬编码中文(UserFormDialog/CredentialManager/RdpAuditViewer/LiveMonitorDialog/ServerFileBrowser/context-loaders)
- [x] context-loaders.ts 全部模板字符串使用 i18n.t() 插值
- [x] `tsc -b` 零错误
- [x] `npm run build` 零错误(✓ built in 18.05s)
- [x] ESLint errors=0, any=0
- [x] zh/en 8102=8102 完全对齐(+17 新键)
- [x] `go build` 零错误
- [x] 17/17 集成回归测试通过(零回归)
- [x] Docker 部署 healthy
@@ -8,27 +8,49 @@ export async function loadAlertsContext(): Promise<string> {
const alerts: JsonData[] = (res as JsonData)?.list || []; const alerts: JsonData[] = (res as JsonData)?.list || [];
if (!alerts.length) return i18n.t('aiops.noAlertsNow'); if (!alerts.length) return i18n.t('aiops.noAlertsNow');
const lines = alerts.slice(0, 15).map((a, i) => const lines = alerts.slice(0, 15).map((a, i) =>
`${i + 1}. [${a.severity || i18n.t('common.unknown')}|${a.status || '-'}] ${a.rule_name || i18n.t('dashboard.stat.alerts')} → 目标:${a.target || '-'} 值:${a.value ?? '-'} 时间:${(a.started_at || '').slice(0, 16)}`, i18n.t('aiops.ctx.alertLine', {
i: i + 1,
severity: a.severity || i18n.t('common.unknown'),
status: a.status || '-',
name: a.rule_name || i18n.t('dashboard.stat.alerts'),
target: a.target || '-',
value: a.value ?? '-',
time: (a.started_at || '').slice(0, 16),
}),
); );
const firing = alerts.filter((a) => a.status === 'firing').length; const firing = alerts.filter((a) => a.status === 'firing').length;
return `共 ${alerts.length} 条告警(firing ${firing} 条),前 ${Math.min(15, alerts.length)} 条:\n${lines.join('\n')}`; return i18n.t('aiops.ctx.alertSummary', {
total: alerts.length,
firing,
shown: Math.min(15, alerts.length),
}) + '\n' + lines.join('\n');
} }
/** 拉取 Agent 实时主机指标,识别高负载主机 */ /** 拉取 Agent 实时主机指标,识别高负载主机 */
export async function loadMetricsContext(): Promise<string> { export async function loadMetricsContext(): Promise<string> {
const res = await agentApi.getLatest(); const res = await agentApi.getLatest();
const hosts: JsonData[] = Array.isArray(res) ? res : (res as JsonData)?.list || []; const hosts: JsonData[] = Array.isArray(res) ? res : (res as JsonData)?.list || [];
if (!hosts.length) return i18n.t('aiops.noAgentData'); if (!hosts.length) return i18n.t('aiops.ctx.noAgentData');
const lines = hosts.slice(0, 20).map((h, i) => { const lines = hosts.slice(0, 20).map((h, i) =>
const cpu = h.cpu_usage ?? '-'; i18n.t('aiops.ctx.metricLine', {
const mem = h.mem_usage ?? '-'; i: i + 1,
return `${i + 1}. ${h.hostname || '-'} | CPU:${cpu}% | 内存:${mem}% (${h.mem_used ?? '-'}/${h.mem_total ?? '-'}GB) | 核数:${h.cpu_cores ?? '-'} | 上报:${(h.report_time || '').slice(0, 16)}`; host: h.hostname || '-',
}); cpu: h.cpu_usage ?? '-',
mem: h.mem_usage ?? '-',
used: h.mem_used ?? '-',
total: h.mem_total ?? '-',
cores: h.cpu_cores ?? '-',
time: (h.report_time || '').slice(0, 16),
}),
);
const hot = hosts.filter((h) => (h.cpu_usage ?? 0) >= 80 || (h.mem_usage ?? 0) >= 80); const hot = hosts.filter((h) => (h.cpu_usage ?? 0) >= 80 || (h.mem_usage ?? 0) >= 80);
const note = hot.length const note = hot.length
? `\n⚠️ 高负载主机 ${hot.length} 台:${hot.map((h) => `${h.hostname}(CPU${h.cpu_usage}%/MEM${h.mem_usage}%)`).join('、')}` ? '\n' + i18n.t('aiops.ctx.highLoadHosts', {
count: hot.length,
hosts: hot.map((h) => `${h.hostname}(CPU${h.cpu_usage}%/MEM${h.mem_usage}%)`).join('、'),
})
: ''; : '';
return `Agent 监控的 ${hosts.length} 台主机实时指标:\n${lines.join('\n')}${note}`; return i18n.t('aiops.ctx.agentMetricsSummary', { count: hosts.length }) + '\n' + lines.join('\n') + note;
} }
/** 拉取仪表盘综合数据,生成运维报告上下文 */ /** 拉取仪表盘综合数据,生成运维报告上下文 */
@@ -42,12 +64,18 @@ export async function loadReportContext(): Promise<string> {
`${i + 1}.${h.hostname || h.ip} CPU:${h.cpu_usage}% MEM:${h.memory_usage}% DISK:${h.disk_usage}% Agent:${h.agent_status}`, `${i + 1}.${h.hostname || h.ip} CPU:${h.cpu_usage}% MEM:${h.memory_usage}% DISK:${h.disk_usage}% Agent:${h.agent_status}`,
); );
return [ return [
`平台概览:服务器:${summary.server_total}(在线${summary.server_online}) | Kubernetes集群:${summary.cluster_total} | 平台告警:${summary.firing_alerts} | Agent未恢复告警:${summary.unresolved_alerts}`, i18n.t('aiops.ctx.platformOverview', {
servers: summary.server_total,
online: summary.server_online,
clusters: summary.cluster_total,
alerts: summary.firing_alerts,
unresolved: summary.unresolved_alerts,
}),
'', '',
'高负载资产:', i18n.t('aiops.ctx.highLoadAssets'),
highLoadLines.join('\n') || i18n.t('aiops.noneFallback'), highLoadLines.join('\n') || i18n.t('aiops.noneFallback'),
'', '',
'最近告警:', i18n.t('aiops.ctx.recentAlerts'),
alertLines.join('\n') || i18n.t('aiops.noneFallback'), alertLines.join('\n') || i18n.t('aiops.noneFallback'),
].join('\n'); ].join('\n');
} }
@@ -60,10 +88,21 @@ export async function loadReportContext(): Promise<string> {
const s: JsonData = stats || {}; const s: JsonData = stats || {};
const ss = s.server_stats || {}, ks = s.kubernetes_stats || {}, as = s.alert_stats || {}, ps = s.pipeline_stats || {}, cs = s.cost_stats || {}; const ss = s.server_stats || {}, ks = s.kubernetes_stats || {}, as = s.alert_stats || {}, ps = s.pipeline_stats || {}, cs = s.cost_stats || {};
const overview = `服务器:${ss.total ?? 0}(运行${ss.running ?? 0}) | Kubernetes集群:${ks.total ?? 0} 节点:${ks.total_nodes ?? 0} Pod:${ks.total_pods ?? 0} | 告警:${as.total ?? 0}(firing ${as.firing ?? 0}) | 流水线:${ps.total ?? 0}(成功率${ps.success_rate ?? 0}%) | 本月成本:¥${cs.month_cost ?? 0}`; const overview = i18n.t('aiops.ctx.overviewFallback', {
servers: ss.total ?? 0,
running: ss.running ?? 0,
clusters: ks.total ?? 0,
nodes: ks.total_nodes ?? 0,
pods: ks.total_pods ?? 0,
alerts: as.total ?? 0,
firing: as.firing ?? 0,
pipelines: ps.total ?? 0,
rate: ps.success_rate ?? 0,
cost: cs.month_cost ?? 0,
});
const alertList: JsonData[] = Array.isArray(alerts) ? alerts : (alerts as JsonData)?.list || []; const alertList: JsonData[] = Array.isArray(alerts) ? alerts : (alerts as JsonData)?.list || [];
const releaseList: JsonData[] = Array.isArray(releases) ? releases : (releases as JsonData)?.list || []; const releaseList: JsonData[] = Array.isArray(releases) ? releases : (releases as JsonData)?.list || [];
const alertLines = alertList.slice(0, 10).map((a: JsonData, i: number) => `${i + 1}.[${a.severity || '?'}|${a.status || '?'}] ${a.rule_name || '-'} → ${a.target || '-'}`); const alertLines = alertList.slice(0, 10).map((a: JsonData, i: number) => `${i + 1}.[${a.severity || '?'}|${a.status || '?'}] ${a.rule_name || '-'} → ${a.target || '-'}`);
const releaseLines = releaseList.slice(0, 10).map((r: JsonData, i: number) => `${i + 1}.${r.app_name || '-'} ${r.version || ''} [${r.environment || '-'}/${r.status || '-'}] by ${r.author || '-'}`); const releaseLines = releaseList.slice(0, 10).map((r: JsonData, i: number) => `${i + 1}.${r.app_name || '-'} ${r.version || ''} [${r.environment || '-'}/${r.status || '-'}] by ${r.author || '-'}`);
return `平台概览:${overview}\n\n最近告警:\n${alertLines.join('\n') || i18n.t('aiops.noneFallback')}\n\n最近发布:\n${releaseLines.join('\n') || i18n.t('aiops.noneFallback')}`; return `${overview}\n\n${i18n.t('aiops.ctx.recentAlerts')}\n${alertLines.join('\n') || i18n.t('aiops.noneFallback')}\n\n${i18n.t('aiops.ctx.recentReleases')}\n${releaseLines.join('\n') || i18n.t('aiops.noneFallback')}`;
} }
@@ -127,7 +127,7 @@ export function ServerFileBrowser({ open, onOpenChange, serverId, serverName }:
}; };
const handleMkdir = async () => { const handleMkdir = async () => {
const name = prompt('输入目录名:'); const name = prompt(i18n.t('common.dirNamePrompt'));
if (!name || !serverId) return; if (!name || !serverId) return;
const newPath = currentPath === '/' ? `/${name}` : `${currentPath}/${name}`; const newPath = currentPath === '/' ? `/${name}` : `${currentPath}/${name}`;
try { try {
@@ -349,7 +349,7 @@ export function CredentialManager() {
size="icon" size="icon"
className="absolute top-2 right-2 h-7 w-7 text-[var(--dg-text-muted)] hover:text-[var(--dg-text-primary)]" className="absolute top-2 right-2 h-7 w-7 text-[var(--dg-text-muted)] hover:text-[var(--dg-text-primary)]"
onClick={() => setShowContent(!showContent)} onClick={() => setShowContent(!showContent)}
title={showContent ? t('common.hidden') : '显示'} title={showContent ? t('common.hidden') : t('common.show')}
> >
{showContent ? <EyeOff className="h-4 w-4" /> : <Eye className="h-4 w-4" />} {showContent ? <EyeOff className="h-4 w-4" /> : <Eye className="h-4 w-4" />}
</Button> </Button>
@@ -139,7 +139,7 @@ export function LiveMonitorDialog({ open, onOpenChange, sessionId, sessionInfo }
const timeout = setTimeout(() => { const timeout = setTimeout(() => {
if (!didOpen) { if (!didOpen) {
setConnectError('连接超时 — 请确认已登录且有活跃会话'); setConnectError(t('system.connectTimeoutActive'));
ws.close(); ws.close();
} }
}, 5000); }, 5000);
@@ -70,7 +70,7 @@ async function drawImageFrame(ctx: CanvasRenderingContext2D, frame: RdpFrame) {
ctx.drawImage(img, frame.x || 0, frame.y || 0, frame.width || img.width, frame.height || img.height); ctx.drawImage(img, frame.x || 0, frame.y || 0, frame.width || img.width, frame.height || img.height);
resolve(); resolve();
}; };
img.onerror = () => reject(new Error('RDP 录屏帧解码失败')); img.onerror = () => reject(new Error(i18n.t('system.rdpFrameError')));
img.src = frame.image || ''; img.src = frame.image || '';
}); });
} }
@@ -242,7 +242,7 @@ export function RdpAuditViewer({ open, onOpenChange, sessionId, mode }: RdpAudit
<DialogDescription className="sr-only">{i18n.t("system.rdpAuditDesc")}</DialogDescription> <DialogDescription className="sr-only">{i18n.t("system.rdpAuditDesc")}</DialogDescription>
<div className="flex items-center justify-between px-4 py-2 border-b border-[var(--dg-border)]"> <div className="flex items-center justify-between px-4 py-2 border-b border-[var(--dg-border)]">
<div className="text-sm font-medium text-[var(--dg-text-primary)]"> <div className="text-sm font-medium text-[var(--dg-text-primary)]">
{mode === 'live' ? 'RDP 实时审计' : `RDP 历史回放 #${sessionId || ''}`} {mode === 'live' ? i18n.t('system.rdpLiveAudit') : i18n.t('system.rdpHistoryReplayId', { id: sessionId || '' })}
</div> </div>
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">
<button type="button" onClick={() => setFullscreen(!fullscreen)} className="p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]"> <button type="button" onClick={() => setFullscreen(!fullscreen)} className="p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]">
@@ -83,7 +83,7 @@ export function UserFormDialog({
<DialogHeader> <DialogHeader>
<DialogTitle className="text-[var(--dg-text-primary)] flex items-center gap-2"> <DialogTitle className="text-[var(--dg-text-primary)] flex items-center gap-2">
<User className="h-5 w-5 dg-text-blue" /> <User className="h-5 w-5 dg-text-blue" />
{editingUser ? t('system.editUser') : '新建用户'} {editingUser ? t('system.editUser') : t('system.createUser')}
</DialogTitle> </DialogTitle>
<DialogDescription className="dg-text-muted"> <DialogDescription className="dg-text-muted">
{editingUser ? t('system.editUserDesc') : t('system.createUserDesc')} {editingUser ? t('system.editUserDesc') : t('system.createUserDesc')}
+21 -2
View File
@@ -665,7 +665,9 @@
"manageAll": "Manage All", "manageAll": "Manage All",
"createNew": "Create New", "createNew": "Create New",
"saveSuccess": "Saved successfully", "saveSuccess": "Saved successfully",
"daysSuffix": "days" "daysSuffix": "days",
"show": "Show",
"dirNamePrompt": "Enter directory name:"
}, },
"menu": { "menu": {
"aiAgentCli": "Agent CLI", "aiAgentCli": "Agent CLI",
@@ -7996,7 +7998,11 @@
}, },
"role": { "role": {
"aiopsGroup": "AIOps Intelligence" "aiopsGroup": "AIOps Intelligence"
} },
"createUser": "Create User",
"rdpFrameError": "RDP recording frame decode failed",
"rdpHistoryReplayId": "RDP History Replay #{{id}}",
"connectTimeoutActive": "Connection timeout — please ensure you are logged in with an active session"
}, },
"aiops": { "aiops": {
"activeCount": "{{count}} active", "activeCount": "{{count}} active",
@@ -8756,6 +8762,19 @@
"defaultImpactWarning": "This alert requires attention. Continued deterioration may affect system stability.", "defaultImpactWarning": "This alert requires attention. Continued deterioration may affect system stability.",
"defaultRecDashboard": "Check the monitoring dashboard for {{target}} to confirm metric trends", "defaultRecDashboard": "Check the monitoring dashboard for {{target}} to confirm metric trends",
"defaultEvent": "Alert event {{id}}" "defaultEvent": "Alert event {{id}}"
},
"ctx": {
"alertSummary": "Total {{total}} alerts ({{firing}} firing), top {{shown}}:",
"alertLine": "{{i}}. [{{severity}}|{{status}}] {{name}} → target:{{target}} value:{{value}} time:{{time}}",
"metricLine": "{{i}}. {{host}} | CPU:{{cpu}}% | MEM:{{mem}}% ({{used}}/{{total}}GB) | Cores:{{cores}} | Report:{{time}}",
"highLoadHosts": "⚠️ {{count}} high-load hosts: {{hosts}}",
"agentMetricsSummary": "Agent-monitored {{count}} hosts real-time metrics:",
"platformOverview": "Platform overview: Servers:{{servers}}(online {{online}}) | K8s clusters:{{clusters}} | Alerts:{{alerts}} | Unresolved agent alerts:{{unresolved}}",
"highLoadAssets": "High-load assets:",
"recentAlerts": "Recent alerts:",
"recentReleases": "Recent releases:",
"overviewFallback": "Servers:{{servers}}(running {{running}}) | K8s clusters:{{clusters}} Nodes:{{nodes}} Pods:{{pods}} | Alerts:{{alerts}}(firing {{firing}}) | Pipelines:{{pipelines}}(success {{rate}}%) | Monthly cost:¥{{cost}}",
"noAgentData": "(No Agent data currently, monitoring Agent may not be deployed)"
} }
}, },
"breadcrumb": { "breadcrumb": {
+21 -2
View File
@@ -665,7 +665,9 @@
"manageAll": "管理全部", "manageAll": "管理全部",
"createNew": "新建", "createNew": "新建",
"saveSuccess": "保存成功", "saveSuccess": "保存成功",
"daysSuffix": "天" "daysSuffix": "天",
"show": "显示",
"dirNamePrompt": "输入目录名:"
}, },
"menu": { "menu": {
"aiAgentCli": "Agent CLI", "aiAgentCli": "Agent CLI",
@@ -7996,7 +7998,11 @@
}, },
"role": { "role": {
"aiopsGroup": "AIOps智能" "aiopsGroup": "AIOps智能"
} },
"createUser": "新建用户",
"rdpFrameError": "RDP 录屏帧解码失败",
"rdpHistoryReplayId": "RDP 历史回放 #{{id}}",
"connectTimeoutActive": "连接超时 — 请确认已登录且有活跃会话"
}, },
"aiops": { "aiops": {
"activeCount": "{{count}} 个活跃", "activeCount": "{{count}} 个活跃",
@@ -8756,6 +8762,19 @@
"defaultImpactWarning": "该告警需要关注,持续恶化可能影响系统稳定性。", "defaultImpactWarning": "该告警需要关注,持续恶化可能影响系统稳定性。",
"defaultRecDashboard": "查看 {{target}} 的监控仪表盘,确认指标趋势", "defaultRecDashboard": "查看 {{target}} 的监控仪表盘,确认指标趋势",
"defaultEvent": "告警事件 {{id}}" "defaultEvent": "告警事件 {{id}}"
},
"ctx": {
"alertSummary": "共 {{total}} 条告警(firing {{firing}} 条),前 {{shown}} 条:",
"alertLine": "{{i}}. [{{severity}}|{{status}}] {{name}} → 目标:{{target}} 值:{{value}} 时间:{{time}}",
"metricLine": "{{i}}. {{host}} | CPU:{{cpu}}% | 内存:{{mem}}% ({{used}}/{{total}}GB) | 核数:{{cores}} | 上报:{{time}}",
"highLoadHosts": "⚠️ 高负载主机 {{count}} 台:{{hosts}}",
"agentMetricsSummary": "Agent 监控的 {{count}} 台主机实时指标:",
"platformOverview": "平台概览:服务器:{{servers}}(在线{{online}}) | Kubernetes集群:{{clusters}} | 平台告警:{{alerts}} | Agent未恢复告警:{{unresolved}}",
"highLoadAssets": "高负载资产:",
"recentAlerts": "最近告警:",
"recentReleases": "最近发布:",
"overviewFallback": "服务器:{{servers}}(运行{{running}}) | Kubernetes集群:{{clusters}} 节点:{{nodes}} Pod:{{pods}} | 告警:{{alerts}}(firing {{firing}}) | 流水线:{{pipelines}}(成功率{{rate}}%) | 本月成本:¥{{cost}}",
"noAgentData": "(当前无 Agent 上报数据,可能未部署监控 Agent)"
} }
}, },
"breadcrumb": { "breadcrumb": {