fix(i18n): 回退到稳定的 32% 覆盖率状态 (tsc + Vite 构建通过)
批量转换脚本引入的语法错误已回退,保留稳定的 i18n 转换: - 翻译词典: 22 namespaces, 3600+ keys - 已接入: 145+ 文件 (Dashboard/Login/K8s 主页面/Monitor/System/Deploy) - 语言切换器在 Header 中可用 (🇨🇳/🇺🇸) - tsc 零错误, Vite 构建成功
This commit is contained in:
1 parent
ecec73989b
commit
72bfb0e12d
191 files changed
+5057
-7592
No files matched your search
@@ -1,4 +1,3 @@
|
||||
import i18n from '@/i18n';
|
||||
// 中间件监控可视化辅助 // Logan.Li
|
||||
|
||||
export interface MwConfigPublic {
|
||||
@@ -59,20 +58,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: 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)' },
|
||||
{ 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)' },
|
||||
];
|
||||
|
||||
export const MYSQL_CHARTS: MwChartDef[] = [
|
||||
{ key: 'mysql_qps', label: 'QPS', color: 'var(--dg-blue)', unit: 'q/s' },
|
||||
{ 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 },
|
||||
{ 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 },
|
||||
];
|
||||
|
||||
export function fmtMemory(bytes: number): string {
|
||||
@@ -139,7 +138,7 @@ export function statusBg(status: string): string {
|
||||
}
|
||||
|
||||
export function redisModeLabel(mode?: string): string {
|
||||
return mode === 'cluster' ? i18n.t('monitor.helpers.s85fe50') : i18n.t('monitor.helpers.s047499');
|
||||
return mode === 'cluster' ? '集群' : '单机';
|
||||
}
|
||||
|
||||
export function redisMemoryPct(metrics: Record<string, number>): number | null {
|
||||
@@ -209,27 +208,27 @@ export function evalMwHealth(target: MwTarget): MwHealthIssue[] {
|
||||
const m = target.latest_metrics || {};
|
||||
const issues: MwHealthIssue[] = [];
|
||||
if (target.status !== 'online') {
|
||||
issues.push({ level: 'crit', message: i18n.t('monitor.helpers.s4ace65') });
|
||||
issues.push({ level: 'crit', message: '实例离线' });
|
||||
return issues;
|
||||
}
|
||||
if (target.description === 'redis') {
|
||||
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') });
|
||||
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%' });
|
||||
const memPct = redisMemoryPct(m);
|
||||
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') });
|
||||
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 逐出' });
|
||||
} else if (target.description === 'mysql') {
|
||||
if (m.mysql_buffer_hit_rate > 0 && m.mysql_buffer_hit_rate < 0.9) {
|
||||
issues.push({ level: 'crit', message: i18n.t('monitor.helpers.s998441') });
|
||||
issues.push({ level: 'crit', message: '缓冲池命中 < 90%' });
|
||||
} else if (m.mysql_buffer_hit_rate > 0 && m.mysql_buffer_hit_rate < 0.95) {
|
||||
issues.push({ level: 'warn', message: i18n.t('monitor.helpers.s41ec17') });
|
||||
issues.push({ level: 'warn', message: '缓冲池命中 < 95%' });
|
||||
}
|
||||
const connPct = mysqlConnPct(m);
|
||||
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') });
|
||||
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: '活跃线程偏多' });
|
||||
}
|
||||
return issues;
|
||||
}
|
||||
@@ -245,8 +244,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 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) });
|
||||
if (diff < 60) return `${diff}s 前`;
|
||||
if (diff < 3600) return `${Math.floor(diff / 60)}m 前`;
|
||||
if (diff < 86400) return `${Math.floor(diff / 3600)}h 前`;
|
||||
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