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:
1 parent
78c27037e3
commit
ecec73989b
166 files changed
+6925
-2800
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import i18n from '@/i18n';
|
||||
// 中间件监控可视化辅助 // Logan.Li
|
||||
|
||||
export interface MwConfigPublic {
|
||||
@@ -58,20 +59,20 @@ export const MYSQL_PRIMARY_KEYS = ['mysql_qps', 'mysql_connections', 'mysql_buff
|
||||
|
||||
export const REDIS_CHARTS: MwChartDef[] = [
|
||||
{ key: 'redis_qps', label: 'QPS', color: 'var(--dg-blue)', unit: 'ops/s' },
|
||||
{ key: 'redis_used_memory', label: '内存占用', color: 'var(--dg-red)', formatter: fmtMemory },
|
||||
{ key: 'redis_hit_rate', label: '命中率', color: 'var(--dg-green)', percent: true },
|
||||
{ key: 'redis_connected_clients', label: '连接数', color: 'var(--dg-cyan)' },
|
||||
{ key: 'redis_db_size', label: 'Key 总数', color: 'var(--dg-purple)' },
|
||||
{ key: 'redis_blocked_clients', label: '阻塞客户端', color: 'var(--dg-orange)' },
|
||||
{ key: 'redis_used_memory', label: i18n.t('monitor.helpers.s44cdb3'), color: 'var(--dg-red)', formatter: fmtMemory },
|
||||
{ key: 'redis_hit_rate', label: i18n.t('monitor.helpers.s678735'), color: 'var(--dg-green)', percent: true },
|
||||
{ key: 'redis_connected_clients', label: i18n.t('k8s.topology.connections'), color: 'var(--dg-cyan)' },
|
||||
{ key: 'redis_db_size', label: i18n.t('monitor.helpers.sc5f65e'), color: 'var(--dg-purple)' },
|
||||
{ key: 'redis_blocked_clients', label: i18n.t('monitor.helpers.s2ad27e'), color: 'var(--dg-orange)' },
|
||||
];
|
||||
|
||||
export const MYSQL_CHARTS: MwChartDef[] = [
|
||||
{ key: 'mysql_qps', label: 'QPS', color: 'var(--dg-blue)', unit: 'q/s' },
|
||||
{ key: 'mysql_connections', label: '连接数', color: 'var(--dg-cyan)' },
|
||||
{ key: 'mysql_threads_running', label: '活跃线程', color: 'var(--dg-purple)' },
|
||||
{ key: 'mysql_buffer_hit_rate', label: '缓冲池命中率', color: 'var(--dg-green)', percent: true },
|
||||
{ key: 'mysql_slow_queries', label: '慢查询速率', color: 'var(--dg-orange)', unit: '次/周期', counterDelta: true },
|
||||
{ key: 'mysql_bytes_sent', label: '发送流量', color: 'var(--dg-amber)', formatter: fmtMemory },
|
||||
{ key: 'mysql_connections', label: i18n.t('k8s.topology.connections'), color: 'var(--dg-cyan)' },
|
||||
{ key: 'mysql_threads_running', label: i18n.t('monitor.helpers.se0f6ab'), color: 'var(--dg-purple)' },
|
||||
{ key: 'mysql_buffer_hit_rate', label: i18n.t('monitor.helpers.sa2d02e'), color: 'var(--dg-green)', percent: true },
|
||||
{ key: 'mysql_slow_queries', label: i18n.t('monitor.helpers.sbd73bc'), color: 'var(--dg-orange)', unit: i18n.t('monitor.helpers.s3878fe'), counterDelta: true },
|
||||
{ key: 'mysql_bytes_sent', label: i18n.t('monitor.helpers.s90d6af'), color: 'var(--dg-amber)', formatter: fmtMemory },
|
||||
];
|
||||
|
||||
export function fmtMemory(bytes: number): string {
|
||||
@@ -138,7 +139,7 @@ export function statusBg(status: string): string {
|
||||
}
|
||||
|
||||
export function redisModeLabel(mode?: string): string {
|
||||
return mode === 'cluster' ? '集群' : '单机';
|
||||
return mode === 'cluster' ? i18n.t('monitor.helpers.s85fe50') : i18n.t('monitor.helpers.s047499');
|
||||
}
|
||||
|
||||
export function redisMemoryPct(metrics: Record<string, number>): number | null {
|
||||
@@ -208,27 +209,27 @@ export function evalMwHealth(target: MwTarget): MwHealthIssue[] {
|
||||
const m = target.latest_metrics || {};
|
||||
const issues: MwHealthIssue[] = [];
|
||||
if (target.status !== 'online') {
|
||||
issues.push({ level: 'crit', message: '实例离线' });
|
||||
issues.push({ level: 'crit', message: i18n.t('monitor.helpers.s4ace65') });
|
||||
return issues;
|
||||
}
|
||||
if (target.description === 'redis') {
|
||||
if (m.redis_hit_rate > 0 && m.redis_hit_rate < 0.8) issues.push({ level: 'crit', message: '命中率 < 80%' });
|
||||
else if (m.redis_hit_rate > 0 && m.redis_hit_rate < 0.9) issues.push({ level: 'warn', message: '命中率 < 90%' });
|
||||
if (m.redis_hit_rate > 0 && m.redis_hit_rate < 0.8) issues.push({ level: 'crit', message: i18n.t('monitor.helpers.sff1d97') });
|
||||
else if (m.redis_hit_rate > 0 && m.redis_hit_rate < 0.9) issues.push({ level: 'warn', message: i18n.t('monitor.helpers.s119023') });
|
||||
const memPct = redisMemoryPct(m);
|
||||
if (memPct != null && memPct > 90) issues.push({ level: 'crit', message: '内存 > 90%' });
|
||||
else if (memPct != null && memPct > 80) issues.push({ level: 'warn', message: '内存 > 80%' });
|
||||
if (m.redis_blocked_clients > 0) issues.push({ level: 'warn', message: '阻塞客户端' });
|
||||
if (m.redis_evicted_keys > 0) issues.push({ level: 'warn', message: 'Key 逐出' });
|
||||
if (memPct != null && memPct > 90) issues.push({ level: 'crit', message: i18n.t('monitor.helpers.s07eee3') });
|
||||
else if (memPct != null && memPct > 80) issues.push({ level: 'warn', message: i18n.t('monitor.helpers.sbb098a') });
|
||||
if (m.redis_blocked_clients > 0) issues.push({ level: 'warn', message: i18n.t('monitor.helpers.s2ad27e') });
|
||||
if (m.redis_evicted_keys > 0) issues.push({ level: 'warn', message: i18n.t('monitor.helpers.sc4db73') });
|
||||
} else if (target.description === 'mysql') {
|
||||
if (m.mysql_buffer_hit_rate > 0 && m.mysql_buffer_hit_rate < 0.9) {
|
||||
issues.push({ level: 'crit', message: '缓冲池命中 < 90%' });
|
||||
issues.push({ level: 'crit', message: i18n.t('monitor.helpers.s998441') });
|
||||
} else if (m.mysql_buffer_hit_rate > 0 && m.mysql_buffer_hit_rate < 0.95) {
|
||||
issues.push({ level: 'warn', message: '缓冲池命中 < 95%' });
|
||||
issues.push({ level: 'warn', message: i18n.t('monitor.helpers.s41ec17') });
|
||||
}
|
||||
const connPct = mysqlConnPct(m);
|
||||
if (connPct != null && connPct > 90) issues.push({ level: 'crit', message: '连接 > 90% 上限' });
|
||||
else if (connPct != null && connPct > 80) issues.push({ level: 'warn', message: '连接 > 80% 上限' });
|
||||
if (m.mysql_threads_running > 20) issues.push({ level: 'warn', message: '活跃线程偏多' });
|
||||
if (connPct != null && connPct > 90) issues.push({ level: 'crit', message: i18n.t('monitor.helpers.s5b95d5') });
|
||||
else if (connPct != null && connPct > 80) issues.push({ level: 'warn', message: i18n.t('monitor.helpers.se0b952') });
|
||||
if (m.mysql_threads_running > 20) issues.push({ level: 'warn', message: i18n.t('monitor.helpers.s56174d') });
|
||||
}
|
||||
return issues;
|
||||
}
|
||||
@@ -244,8 +245,8 @@ export function fmtLastSeen(iso?: string): string {
|
||||
const d = new Date(iso);
|
||||
if (Number.isNaN(d.getTime())) return '--';
|
||||
const diff = Math.floor((Date.now() - d.getTime()) / 1000);
|
||||
if (diff < 60) return `${diff}s 前`;
|
||||
if (diff < 3600) return `${Math.floor(diff / 60)}m 前`;
|
||||
if (diff < 86400) return `${Math.floor(diff / 3600)}h 前`;
|
||||
if (diff < 60) return i18n.t('monitor.helpers.s36683c', { diff: diff });
|
||||
if (diff < 3600) return i18n.t('monitor.helpers.s18b0c1', { Math.floor(diff / 60): Math.floor(diff / 60) });
|
||||
if (diff < 86400) return i18n.t('monitor.helpers.s47d820', { Math.floor(diff / 3600): Math.floor(diff / 3600) });
|
||||
return `${d.getMonth() + 1}/${d.getDate()} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`;
|
||||
}
|
||||
Reference in new issue
Block a user