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
@@ -24,9 +24,9 @@ import {
|
||||
|
||||
import { kubernetesApi } from '@/api';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { DeploymentDetail } from './DeploymentDetail';
|
||||
import type { JsonData } from '@/types/common';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export function KubernetesWorkloads() {
|
||||
const { t } = useTranslation();
|
||||
@@ -121,7 +121,7 @@ export function KubernetesWorkloads() {
|
||||
const newReplicas = (dep.replicas || 0) + delta;
|
||||
if (newReplicas < 0) return;
|
||||
await kubernetesApi.scaleDeployment(selectedCluster, dep.namespace, dep.name, newReplicas);
|
||||
toast({ title: t('kubernetes.kubernetesworkloads.s0b3ea1'), description: t('kubernetes.kubernetesworkloads.scf7f1c', { dep.name: dep.name, newReplicas: newReplicas }) });
|
||||
toast({ title: t('k8s.workloads.scaleSuccess'), description: t('k8s.workloads.scaleDesc', { name: dep.name, count: newReplicas }) });
|
||||
loadData();
|
||||
} catch (e) {
|
||||
toast({ title: t('common.operationFailed'), description: e?.message || String(e), variant: 'destructive' });
|
||||
@@ -146,13 +146,13 @@ export function KubernetesWorkloads() {
|
||||
<div className="space-y-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold text-[var(--dg-text-primary)]">{t('menu.workloads')}</h1>
|
||||
<p className="text-sm dg-text-muted mt-1">{t('kubernetes.kubernetesworkloads.sf90ced')}</p>
|
||||
<h1 className="text-2xl font-bold text-[var(--dg-text-primary)]">{t('k8s.workloads.title')}</h1>
|
||||
<p className="text-sm dg-text-muted mt-1">{t('k8s.workloads.subtitle')}</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Select value={selectedCluster} onValueChange={(v) => { setSelectedCluster(v); setSelectedNamespace('all'); }}>
|
||||
<SelectTrigger className="w-48 h-9 dg-input">
|
||||
<SelectValue placeholder=t('k8s.topology.selectCluster') />
|
||||
<SelectValue placeholder={t('k8s.workloads.selectCluster')} />
|
||||
</SelectTrigger>
|
||||
<SelectContent className="dg-input">
|
||||
{clusters.map((c) => (
|
||||
@@ -162,10 +162,10 @@ export function KubernetesWorkloads() {
|
||||
</Select>
|
||||
<Select value={selectedNamespace} onValueChange={setSelectedNamespace}>
|
||||
<SelectTrigger className="w-40 h-9 dg-input">
|
||||
<SelectValue placeholder=t('k8s.column.namespace') />
|
||||
<SelectValue placeholder={t('k8s.workloads.namespace')} />
|
||||
</SelectTrigger>
|
||||
<SelectContent className="dg-input max-h-[300px]">
|
||||
<SelectItem value="all">{t('kubernetes.namespace.allNamespaces')}</SelectItem>
|
||||
<SelectItem value="all">{t('k8s.workloads.allNamespaces')}</SelectItem>
|
||||
{namespaces.map((ns) => (
|
||||
<SelectItem key={ns} value={ns}>{ns}</SelectItem>
|
||||
))}
|
||||
@@ -180,7 +180,7 @@ export function KubernetesWorkloads() {
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
||||
{[
|
||||
{ label: 'Deployment', value: deployments.length, icon: <Boxes className="h-5 w-5" />, color: 'text-rose-400' },
|
||||
{ label: t('kubernetes.kubernetesworkloads.s83481f'), value: pods.length, icon: <Container className="h-5 w-5" />, color: 'dg-text-blue' },
|
||||
{ label: t('k8s.workloads.podTotal'), value: pods.length, icon: <Container className="h-5 w-5" />, color: 'dg-text-blue' },
|
||||
{ label: 'Running', value: pods.filter((p) => p.status === 'Running').length, icon: <Container className="h-5 w-5" />, color: 'dg-text-green' },
|
||||
{ label: t('common.abnormal'), value: pods.filter((p) => ['Failed', 'Pending'].includes(p.status)).length, icon: <Container className="h-5 w-5" />, color: 'dg-text-red' },
|
||||
].map((s) => (
|
||||
@@ -200,7 +200,7 @@ export function KubernetesWorkloads() {
|
||||
|
||||
<div className="relative w-56">
|
||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 dg-text-muted" />
|
||||
<Input placeholder=t('kubernetes.kubernetesworkloads.s64e327') value={search} onChange={(e) => setSearch(e.target.value)} className="pl-9 h-9 dg-input" />
|
||||
<Input placeholder={t('common.search') + '...'} value={search} onChange={(e) => setSearch(e.target.value)} className="pl-9 h-9 dg-input" />
|
||||
</div>
|
||||
|
||||
<Tabs value={activeTab} onValueChange={setActiveTab}>
|
||||
@@ -217,7 +217,7 @@ export function KubernetesWorkloads() {
|
||||
<TableRow className="border-[var(--dg-border)] hover:bg-transparent">
|
||||
<TableHead className="dg-text-secondary">{t('common.name')}</TableHead>
|
||||
<TableHead className="dg-text-secondary">{t('k8s.column.namespace')}</TableHead>
|
||||
<TableHead className="dg-text-secondary">{t('kubernetes.kubernetesworkloads.s0428b3')}</TableHead>
|
||||
<TableHead className="dg-text-secondary">{t('k8s.column.replicas')}</TableHead>
|
||||
<TableHead className="dg-text-secondary">{t('k8s.column.image')}</TableHead>
|
||||
<TableHead className="dg-text-secondary w-[140px]">{t('common.actions')}</TableHead>
|
||||
</TableRow>
|
||||
@@ -226,7 +226,7 @@ export function KubernetesWorkloads() {
|
||||
{loading ? (
|
||||
<TableRow><TableCell colSpan={5} className="text-center dg-text-muted py-12"><Loader2 className="h-5 w-5 animate-spin mx-auto mb-2" />{t('common.loading')}</TableCell></TableRow>
|
||||
) : filteredDeps.length === 0 ? (
|
||||
<TableRow><TableCell colSpan={5} className="text-center dg-text-muted py-12"><Boxes className="h-8 w-8 mx-auto mb-2 opacity-50" />{t('kubernetes.kubernetesworkloads.s5689d3')}</TableCell></TableRow>
|
||||
<TableRow><TableCell colSpan={5} className="text-center dg-text-muted py-12"><Boxes className="h-8 w-8 mx-auto mb-2 opacity-50" />{t('k8s.workloads.noDeployment')}</TableCell></TableRow>
|
||||
) : (
|
||||
filteredDeps.map((d) => (
|
||||
<TableRow key={d.id || d.name} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-hover)] cursor-pointer"
|
||||
@@ -253,16 +253,16 @@ export function KubernetesWorkloads() {
|
||||
<TableCell onClick={(e) => e.stopPropagation()}>
|
||||
<div className="flex items-center gap-0.5">
|
||||
<Button variant="ghost" size="icon" className="h-7 w-7 dg-text-secondary hover:text-[var(--dg-text-primary)]"
|
||||
title=t('kubernetes.kubernetesworkloads.sd4db1c') disabled={(d.replicas || 0) <= 0}
|
||||
title={t('k8s.workloads.decreaseReplica')} disabled={(d.replicas || 0) <= 0}
|
||||
onClick={() => handleQuickScale(d, -1)}>
|
||||
<Minus className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" className="h-7 w-7 dg-text-secondary hover:text-[var(--dg-text-primary)]"
|
||||
title=t('kubernetes.kubernetesworkloads.se80820') onClick={() => handleQuickScale(d, 1)}>
|
||||
title={t('k8s.workloads.increaseReplica')} onClick={() => handleQuickScale(d, 1)}>
|
||||
<Plus className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" className="h-7 w-7 dg-text-secondary hover:dg-text-blue"
|
||||
title=t('common.viewDetail') onClick={() => setSelectedDeployment({ name: d.name, namespace: d.namespace })}>
|
||||
title={t('common.viewDetail')} onClick={() => setSelectedDeployment({ name: d.name, namespace: d.namespace })}>
|
||||
<Eye className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
</div>
|
||||
@@ -285,10 +285,10 @@ export function KubernetesWorkloads() {
|
||||
<TableHead className="dg-text-secondary">{t('common.name')}</TableHead>
|
||||
<TableHead className="dg-text-secondary">{t('k8s.column.namespace')}</TableHead>
|
||||
<TableHead className="dg-text-secondary">{t('common.status')}</TableHead>
|
||||
<TableHead className="dg-text-secondary">{t('k8s.tab.nodes')}</TableHead>
|
||||
<TableHead className="dg-text-secondary">{t('k8s.column.node')}</TableHead>
|
||||
<TableHead className="dg-text-secondary">CPU</TableHead>
|
||||
<TableHead className="dg-text-secondary">{t('k8s.pods.memory')}</TableHead>
|
||||
<TableHead className="dg-text-secondary">{t('common.reboot')}</TableHead>
|
||||
<TableHead className="dg-text-secondary">{t('k8s.column.memory')}</TableHead>
|
||||
<TableHead className="dg-text-secondary">{t('k8s.column.restartCount')}</TableHead>
|
||||
<TableHead className="dg-text-secondary">{t('k8s.column.image')}</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
@@ -296,7 +296,7 @@ export function KubernetesWorkloads() {
|
||||
{loading ? (
|
||||
<TableRow><TableCell colSpan={8} className="text-center dg-text-muted py-12"><Loader2 className="h-5 w-5 animate-spin mx-auto mb-2" />{t('common.loading')}</TableCell></TableRow>
|
||||
) : filteredPods.length === 0 ? (
|
||||
<TableRow><TableCell colSpan={8} className="text-center dg-text-muted py-12"><Container className="h-8 w-8 mx-auto mb-2 opacity-50" />{t('k8s.deploymentDetail.noPod')}</TableCell></TableRow>
|
||||
<TableRow><TableCell colSpan={8} className="text-center dg-text-muted py-12"><Container className="h-8 w-8 mx-auto mb-2 opacity-50" />{t('k8s.workloads.noPod')}</TableCell></TableRow>
|
||||
) : (
|
||||
filteredPods.map((p) => (
|
||||
<TableRow key={p.id} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-hover)]">
|
||||
|
||||
Reference in new issue
Block a user