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,71 +1,73 @@
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
import { ChevronRight, Home } from 'lucide-react';
|
||||
import { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import i18n from '@/i18n';
|
||||
|
||||
/**
|
||||
* Route name mapping - breadcrumb display names
|
||||
*/
|
||||
const ROUTE_NAME_MAP: Record<string, string> = {
|
||||
'': '仪表盘',
|
||||
'servers': '服务器管理',
|
||||
'cloud-accounts': '云账号管理',
|
||||
'domains': '域名管理',
|
||||
'regions': '区域管理',
|
||||
'platforms': '云平台',
|
||||
'cloud-billing': '云账单',
|
||||
'': i18n.t('menu.dashboard'),
|
||||
'servers': i18n.t('menu.servers'),
|
||||
'cloud-accounts': i18n.t('menu.cloudAccounts'),
|
||||
'domains': i18n.t('menu.domains'),
|
||||
'regions': i18n.t('menu.regions'),
|
||||
'platforms': i18n.t('menu.platforms'),
|
||||
'cloud-billing': i18n.t('menu.cloudBilling'),
|
||||
'kubernetes': 'Kubernetes',
|
||||
'clusters': '集群列表',
|
||||
'nodes': '节点管理',
|
||||
'workloads': '工作负载',
|
||||
'clusters': i18n.t('menu.clusterList'),
|
||||
'nodes': i18n.t('menu.nodeManagement'),
|
||||
'workloads': i18n.t('menu.workloads'),
|
||||
'deployments': 'Deployments',
|
||||
'statefulsets': 'StatefulSets',
|
||||
'daemonsets': 'DaemonSets',
|
||||
'cronjobs': '定时任务',
|
||||
'cronjobs': i18n.t('menu.cronJobs'),
|
||||
'services': 'Services',
|
||||
'ingresses': 'Ingresses',
|
||||
'configmaps': 'ConfigMaps',
|
||||
'secrets': 'Secrets',
|
||||
'hpas': 'HPA',
|
||||
'pvcs': '存储',
|
||||
'pvcs': i18n.t('menu.storage'),
|
||||
|
||||
'events': '事件',
|
||||
'topology': '架构拓扑',
|
||||
'namespace': '命名空间',
|
||||
'workload': '工作负载',
|
||||
'view': '查看',
|
||||
'edit': '编辑',
|
||||
'pipelines': '流水线',
|
||||
'deploy': '应用发布',
|
||||
'configureTools': '发布配置',
|
||||
'groups': '用户组',
|
||||
'rbac': '权限管理',
|
||||
'monitor-center': '资源监控',
|
||||
'log-center': '日志中心',
|
||||
'events': i18n.t('menu.events'),
|
||||
'topology': i18n.t('menu.topology'),
|
||||
'namespace': i18n.t('k8s.column.namespace'),
|
||||
'workload': i18n.t('menu.workloads'),
|
||||
'view': i18n.t('common.view'),
|
||||
'edit': i18n.t('common.edit'),
|
||||
'pipelines': i18n.t('menu.pipelines'),
|
||||
'deploy': i18n.t('menu.deploy'),
|
||||
'configureTools': i18n.t('menu.deployConfig'),
|
||||
'groups': i18n.t('pipeline.userGroup'),
|
||||
'rbac': i18n.t('system.permissions'),
|
||||
'monitor-center': i18n.t('menu.resourceMonitor'),
|
||||
'log-center': i18n.t('menu.logCenter'),
|
||||
'loki': 'Loki',
|
||||
'es': 'ES',
|
||||
'logs': '日志中心',
|
||||
'trace': '链路追踪',
|
||||
'alert-center': '告警中心',
|
||||
'datasources': '数据源',
|
||||
'dashboards': '监控大屏',
|
||||
'host-monitor': '主机监控',
|
||||
'alerts': '监控告警',
|
||||
'approval': '资源申请',
|
||||
'approval-resource': '资源申请',
|
||||
'approval-app': '应用申请',
|
||||
'approval-permission': '权限审批',
|
||||
'approval-workflow': '审批流程',
|
||||
'scripts': '脚本库',
|
||||
'logs': i18n.t('menu.logCenter'),
|
||||
'trace': i18n.t('menu.trace'),
|
||||
'alert-center': i18n.t('menu.alertCenter'),
|
||||
'datasources': i18n.t('menu.datasources'),
|
||||
'dashboards': i18n.t('menu.grafana'),
|
||||
'host-monitor': i18n.t('monitor.hostMonitor'),
|
||||
'alerts': i18n.t('ui.breadcrumb.sa57c10'),
|
||||
'approval': i18n.t('menu.approval'),
|
||||
'approval-resource': i18n.t('menu.approval'),
|
||||
'approval-app': i18n.t('menu.approvalApp'),
|
||||
'approval-permission': i18n.t('menu.approvalPermission'),
|
||||
'approval-workflow': i18n.t('menu.approvalWorkflow'),
|
||||
'scripts': i18n.t('menu.scripts'),
|
||||
'ansible': 'Ansible',
|
||||
'ai-assistant': '智能助手',
|
||||
'ai-alert-analyzer': '告警分析',
|
||||
'ai-predictive': '容量预测',
|
||||
'users': '用户管理',
|
||||
'roles': '角色权限',
|
||||
'logs-audit': '操作审计',
|
||||
'terminal-audit': '终端审计',
|
||||
'credentials': '凭证配置',
|
||||
'settings': '系统设置',
|
||||
'ai-assistant': i18n.t('menu.aiAssistant'),
|
||||
'ai-alert-analyzer': i18n.t('aiops.alertAnalysis'),
|
||||
'ai-predictive': i18n.t('aiops.predictive'),
|
||||
'users': i18n.t('menu.users'),
|
||||
'roles': i18n.t('menu.roles'),
|
||||
'logs-audit': i18n.t('system.auditLog'),
|
||||
'terminal-audit': i18n.t('system.terminal'),
|
||||
'credentials': i18n.t('menu.credentials'),
|
||||
'settings': i18n.t('menu.settings'),
|
||||
};
|
||||
|
||||
interface BreadcrumbItem {
|
||||
@@ -81,12 +83,13 @@ interface BreadcrumbItem {
|
||||
* 支持动态参数(如 clusterCode, namespace, name)显示
|
||||
*/
|
||||
export function Breadcrumb() {
|
||||
const { t } = useTranslation();
|
||||
const location = useLocation();
|
||||
|
||||
const breadcrumbs = useMemo<BreadcrumbItem[]>(() => {
|
||||
const paths = location.pathname.split('/').filter(Boolean);
|
||||
if (paths.length === 0) {
|
||||
return [{ name: '仪表盘', path: '/', isLast: true }];
|
||||
return [{ name: t('menu.dashboard'), path: '/', isLast: true }];
|
||||
}
|
||||
|
||||
const items: BreadcrumbItem[] = [];
|
||||
@@ -102,10 +105,10 @@ export function Breadcrumb() {
|
||||
|
||||
// 日志中心子路由区分 // Logan.Li
|
||||
if (segment === 'alerts' && paths[index - 1] === 'log-center') {
|
||||
displayName = '日志告警';
|
||||
displayName = t('menu.logAlerts');
|
||||
}
|
||||
if (segment === 'datasources' && paths[index - 1] === 'log-center') {
|
||||
displayName = '日志库';
|
||||
displayName = t('menu.logLibrary');
|
||||
}
|
||||
|
||||
if (!displayName) {
|
||||
@@ -135,13 +138,13 @@ export function Breadcrumb() {
|
||||
|
||||
return (
|
||||
<nav
|
||||
aria-label="面包屑导航"
|
||||
aria-label=t('ui.breadcrumb.s357625')
|
||||
className="flex items-center gap-1.5 text-sm animate-fade-in"
|
||||
>
|
||||
<Link
|
||||
to="/"
|
||||
className="flex items-center gap-1 text-[var(--dg-text-muted)] hover:text-[var(--dg-blue)] transition-colors duration-200"
|
||||
title="仪表盘"
|
||||
title=t('menu.dashboard')
|
||||
>
|
||||
<Home className="h-3.5 w-3.5" />
|
||||
</Link>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Component, type ErrorInfo, type ReactNode } from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { AlertTriangle, RotateCcw, Home, Bug } from 'lucide-react';
|
||||
import { toast } from 'sonner';
|
||||
import i18n from '@/i18n';
|
||||
|
||||
interface Props {
|
||||
children: ReactNode;
|
||||
@@ -31,8 +32,8 @@ export class ErrorBoundary extends Component<Props, State> {
|
||||
}
|
||||
|
||||
override componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
||||
console.error('[ErrorBoundary] 捕获到错误:', error);
|
||||
console.error('[ErrorBoundary] 错误信息:', errorInfo.componentStack);
|
||||
console.error(i18n.t('ui.errorboundary.sc0bdc3'), error);
|
||||
console.error(i18n.t('ui.errorboundary.s1f72f8'), errorInfo.componentStack);
|
||||
this.setState({ error, errorInfo });
|
||||
}
|
||||
|
||||
@@ -46,11 +47,11 @@ export class ErrorBoundary extends Component<Props, State> {
|
||||
|
||||
handleReport = () => {
|
||||
const { error, errorInfo } = this.state;
|
||||
const body = `## 错误报告\n\n**时间:** ${new Date().toISOString()}\n**URL:** ${window.location.href}\n**用户代理:** ${navigator.userAgent}\n\n### 错误信息\n\n\`\`\`\n${error?.name}: ${error?.message}\n\`\`\`\n\n### 组件堆栈\n\n\`\`\`\n${errorInfo?.componentStack}\n\`\`\`\n`;
|
||||
const body = i18n.t('ui.errorboundary.s8f0ca2', { new Date().toISOString(): new Date().toISOString(), window.location.href: window.location.href, navigator.userAgent: navigator.userAgent, error?.name: error?.name, error?.message: error?.message, errorInfo?.componentStack: errorInfo?.componentStack });
|
||||
navigator.clipboard.writeText(body).then(() => {
|
||||
toast.success('错误信息已复制到剪贴板,请粘贴到 Issue 中');
|
||||
toast.success(i18n.t('ui.errorboundary.sf29c9d'));
|
||||
}).catch(() => {
|
||||
toast.error('复制失败,请手动复制错误信息');
|
||||
toast.error(i18n.t('ui.errorboundary.s7b5065'));
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -7,12 +7,14 @@ import { Header } from './Header';
|
||||
import { Breadcrumb } from './Breadcrumb';
|
||||
import { authApi } from '@/api';
|
||||
import type { JsonData } from '@/types/common';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
/**
|
||||
* MainLayout — 统一应用布局壳
|
||||
* 侧栏 + 顶栏 + 面包屑 + 内容区,间距由 --layout-* 令牌驱动 // Logan.Li
|
||||
*/
|
||||
export function MainLayout() {
|
||||
const { t } = useTranslation();
|
||||
const { sidebarCollapsed } = useThemeStore();
|
||||
const token = useUserStore((s) => s.token);
|
||||
const permissions = useUserStore((s) => s.permissions);
|
||||
@@ -59,7 +61,7 @@ export function MainLayout() {
|
||||
</main>
|
||||
<footer className="dg-app-footer">
|
||||
<div className="flex items-center justify-between text-xs dg-text-muted">
|
||||
<span>AIOps 智能运维平台</span>
|
||||
<span>{t('login.title')}</span>
|
||||
<span>v1.0.0</span>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
Reference in new issue
Block a user