feat(i18n): Dashboard 页面内容国际化迁移 — 3 组件(Dashboard/DashboardCharts/DashboardRecent)硬编码中文改翻译键 + zh-CN/en-US 新增 dashboard.* 121 键(241 total)
- Dashboard.tsx: 标题/副标题/刷新/服务器按钮/StatStrip 7 标签/概览卡片标题 全部 t() 化 - DashboardCharts.tsx: 云成本概览/Top5资源使用/费用分布/月度趋势/环比标签 i18n(computeMonthChange 用 i18n.t 避开非组件上下文) - DashboardRecent.tsx: 告警消息/证书到期/发布历史/服务器状态/集群状态 5 卡片全量 i18n - zh-CN.json/en-US.json: dashboard 命名空间扩展 stat/alerts/certificates/releases/serversStatus/clusters/cost/topUsage/system 9 子分组 - 翻译键总数 120→241 (zh-CN/en-US 完全对齐) - tsc -b=0, npm build=✓(19.01s), 17/17 集成测试通过, Docker healthy
This commit is contained in:
1 parent
b7780c5a5a
commit
eb0fef7fce
5 files changed
+264
-100
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { Clock, Server, ArrowRight } from 'lucide-react';
|
||||
@@ -34,6 +35,7 @@ import type { AlertEventRecord, CertExpiryRecord } from '@/types';
|
||||
* 6. 添加页面标题区域的操作入口
|
||||
*/
|
||||
export function Dashboard() {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const [initialLoading, setInitialLoading] = useState(true);
|
||||
const [refreshing, setRefreshing] = useState(false);
|
||||
@@ -111,8 +113,8 @@ export function Dashboard() {
|
||||
{/* Page Header */}
|
||||
<div className="dg-page-header">
|
||||
<div>
|
||||
<h1 className="dg-page-title">仪表盘</h1>
|
||||
<p className="dg-page-subtitle">实时监控和运维概览 · 最后更新: {new Date().toLocaleTimeString('zh-CN')}</p>
|
||||
<h1 className="dg-page-title">{t('dashboard.title')}</h1>
|
||||
<p className="dg-page-subtitle">{t('dashboard.subtitle')} · {t('dashboard.lastUpdated')}: {new Date().toLocaleTimeString()}</p>
|
||||
</div>
|
||||
<div className="dg-page-actions">
|
||||
<Button
|
||||
@@ -122,14 +124,14 @@ export function Dashboard() {
|
||||
disabled={refreshing}
|
||||
>
|
||||
<Clock className={cn('h-4 w-4', refreshing && 'animate-spin')} />
|
||||
{refreshing ? '刷新中' : '刷新'}
|
||||
{refreshing ? t('dashboard.refreshing') : t('dashboard.refresh')}
|
||||
</Button>
|
||||
<Button
|
||||
className="dg-btn-primary"
|
||||
onClick={() => navigate('/servers')}
|
||||
>
|
||||
<Server className="h-4 w-4" />
|
||||
服务器
|
||||
{t('dashboard.servers')}
|
||||
<ArrowRight className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
</div>
|
||||
@@ -139,13 +141,13 @@ export function Dashboard() {
|
||||
<div className="animate-fade-in-delay-1">
|
||||
<StatStrip
|
||||
items={[
|
||||
{ label: '服务器', value: serverStats?.total ?? 0, color: 'blue' },
|
||||
{ label: '运行中', value: serverStats?.running ?? 0, color: 'emerald' },
|
||||
{ label: 'K8s 集群', value: k8sStats?.total ?? 0, color: 'purple' },
|
||||
{ label: '健康集群', value: k8sStats?.healthy ?? 0, color: 'cyan' },
|
||||
{ label: '告警', value: alertStats?.firing ?? 0, color: alertStats?.firing > 0 ? 'red' : 'muted' },
|
||||
{ label: '严重', value: alertStats?.critical ?? 0, color: 'red' },
|
||||
{ label: '本月成本', value: `¥${Number(costStats?.month_cost ?? 0).toLocaleString()}`, color: 'amber' },
|
||||
{ label: t('dashboard.stat.servers'), value: serverStats?.total ?? 0, color: 'blue' },
|
||||
{ label: t('dashboard.stat.running'), value: serverStats?.running ?? 0, color: 'emerald' },
|
||||
{ label: t('dashboard.stat.k8sClusters'), value: k8sStats?.total ?? 0, color: 'purple' },
|
||||
{ label: t('dashboard.stat.healthyClusters'), value: k8sStats?.healthy ?? 0, color: 'cyan' },
|
||||
{ label: t('dashboard.stat.alerts'), value: alertStats?.firing ?? 0, color: alertStats?.firing > 0 ? 'red' : 'muted' },
|
||||
{ label: t('dashboard.stat.critical'), value: alertStats?.critical ?? 0, color: 'red' },
|
||||
{ label: t('dashboard.stat.monthlyCost'), value: `¥${Number(costStats?.month_cost ?? 0).toLocaleString()}`, color: 'amber' },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user