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
@@ -23,7 +23,6 @@ import {
|
||||
} from '@/components/ui/dialog';
|
||||
|
||||
import {
|
||||
import { useTranslation } from 'react-i18next';
|
||||
Cpu,
|
||||
MemoryStick,
|
||||
HardDrive,
|
||||
@@ -42,7 +41,6 @@ import { useTranslation } from 'react-i18next';
|
||||
// ============ 组件 ============
|
||||
|
||||
export function AgentMonitor() {
|
||||
const { t } = useTranslation();
|
||||
const [hosts, setHosts] = useState<AgentHostRecord[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [refreshing, setRefreshing] = useState(false);
|
||||
@@ -70,7 +68,7 @@ export function AgentMonitor() {
|
||||
if (fresh) setSelectedHost(fresh);
|
||||
}
|
||||
} catch (err) {
|
||||
if (!silent) toast.error(t('agent.agentmonitor.s5760f6'));
|
||||
if (!silent) toast.error('加载主机列表失败');
|
||||
console.error(err);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -99,7 +97,7 @@ export function AgentMonitor() {
|
||||
// 提交远程命令(直连 SSH 即时返回)
|
||||
const submitCommand = async () => {
|
||||
if (!cmdCommand.trim()) {
|
||||
toast.error(t('agent.agentmonitor.s9358aa'));
|
||||
toast.error('请输入要执行的命令');
|
||||
return;
|
||||
}
|
||||
setCmdSubmitting(true);
|
||||
@@ -113,11 +111,11 @@ export function AgentMonitor() {
|
||||
const resData = (res?.data ?? {}) as Record<string, unknown>;
|
||||
setCmdResult({
|
||||
status: res?.code === 200 ? 'completed' : 'failed',
|
||||
result: (resData.output as string) || (res?.message as string) || t('agent.agentmonitor.s26d45b'),
|
||||
result: (resData.output as string) || (res?.message as string) || '无输出',
|
||||
error: resData.error as string | undefined,
|
||||
});
|
||||
} catch (err) {
|
||||
setCmdResult({ status: 'failed', result: err?.message || t('automation.scriptFailed') });
|
||||
setCmdResult({ status: 'failed', result: err?.message || '执行失败' });
|
||||
} finally {
|
||||
setCmdSubmitting(false);
|
||||
loadLatest(true);
|
||||
@@ -131,9 +129,9 @@ export function AgentMonitor() {
|
||||
const onlineCount = hosts.filter((h) => isOnline(h.last_report || h.last_reported_at || h.updated_at)).length;
|
||||
|
||||
const stats = [
|
||||
{ label: t('agent.agentmonitor.sd94cd2'), value: hosts.length, icon: Server, color: 'dg-text-blue' },
|
||||
{ label: t('common.online'), value: onlineCount, icon: Wifi, color: 'dg-text-green' },
|
||||
{ label: t('common.offline'), value: hosts.length - onlineCount, icon: WifiOff, color: 'dg-text-red' },
|
||||
{ label: '主机总数', value: hosts.length, icon: Server, color: 'dg-text-blue' },
|
||||
{ label: '在线', value: onlineCount, icon: Wifi, color: 'dg-text-green' },
|
||||
{ label: '离线', value: hosts.length - onlineCount, icon: WifiOff, color: 'dg-text-red' },
|
||||
];
|
||||
|
||||
return (
|
||||
@@ -141,8 +139,8 @@ export function AgentMonitor() {
|
||||
{/* 页头 */}
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h2 className="text-xl font-semibold text-[var(--dg-text-primary)]">{t('agent.agentMonitor')}</h2>
|
||||
<p className="text-sm dg-text-secondary mt-0.5">{t('agent.agentmonitor.sa75d75')}</p>
|
||||
<h2 className="text-xl font-semibold text-[var(--dg-text-primary)]">Agent 监控</h2>
|
||||
<p className="text-sm dg-text-secondary mt-0.5">实时监控 Agent 上报的主机指标</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
@@ -188,14 +186,14 @@ export function AgentMonitor() {
|
||||
<Card className="dg-card">
|
||||
<CardContent className="flex items-center justify-center py-16">
|
||||
<Loader2 className="h-6 w-6 animate-spin dg-text-muted" />
|
||||
<span className="ml-2 dg-text-secondary">{t('common.loading')}</span>
|
||||
<span className="ml-2 dg-text-secondary">加载中...</span>
|
||||
</CardContent>
|
||||
</Card>
|
||||
) : hosts.length === 0 ? (
|
||||
<Card className="dg-card">
|
||||
<CardContent className="flex flex-col items-center justify-center py-16">
|
||||
<Server className="h-10 w-10 dg-text-muted mb-3" />
|
||||
<p className="dg-text-secondary">{t('agent.noAgentData')}</p>
|
||||
<p className="dg-text-secondary">暂无 Agent 上报数据</p>
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={() => setWizardOpen(true)}
|
||||
@@ -242,8 +240,8 @@ export function AgentMonitor() {
|
||||
{/* 指标条 */}
|
||||
<div className="space-y-2">
|
||||
<MetricBar icon={Cpu} label="CPU" value={cpu} />
|
||||
<MetricBar icon={MemoryStick} label=t('k8s.pods.memory') value={mem} />
|
||||
<MetricBar icon={HardDrive} label=t('dashboard.topUsage.disk') value={disk} />
|
||||
<MetricBar icon={MemoryStick} label="内存" value={mem} />
|
||||
<MetricBar icon={HardDrive} label="磁盘" value={disk} />
|
||||
</div>
|
||||
|
||||
{/* 端口 & 时间 */}
|
||||
@@ -309,7 +307,7 @@ export function AgentMonitor() {
|
||||
<div className="space-y-3">
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)] text-xs">{t('agent.installTarget')}</Label>
|
||||
<Label className="text-[var(--dg-text-secondary)] text-xs">目标主机</Label>
|
||||
<Input
|
||||
value={cmdHost}
|
||||
onChange={(e) => setCmdHost(e.target.value)}
|
||||
@@ -320,18 +318,18 @@ export function AgentMonitor() {
|
||||
</div>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)] text-xs">{t('system.terminalCommand')}</Label>
|
||||
<Label className="text-[var(--dg-text-secondary)] text-xs">命令</Label>
|
||||
<Textarea
|
||||
value={cmdCommand}
|
||||
onChange={(e) => setCmdCommand(e.target.value)}
|
||||
placeholder=t('agent.agentmonitor.s6e62a5')
|
||||
placeholder="例如:free -m && df -h"
|
||||
rows={3}
|
||||
className="bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] font-mono text-sm resize-none"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="w-40 space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)] text-xs">{t('monitor.probeTimeout')}</Label>
|
||||
<Label className="text-[var(--dg-text-secondary)] text-xs">超时(秒)</Label>
|
||||
<Input
|
||||
type="number"
|
||||
value={cmdTimeout}
|
||||
@@ -344,7 +342,7 @@ export function AgentMonitor() {
|
||||
{cmdResult && (
|
||||
<div className="space-y-1.5">
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="text-[var(--dg-text-secondary)] text-xs">{t('automation.execResult')}</Label>
|
||||
<Label className="text-[var(--dg-text-secondary)] text-xs">执行结果</Label>
|
||||
<Badge
|
||||
className={
|
||||
cmdResult.status === 'success' || cmdResult.status === 'done' || cmdResult.status === 'completed'
|
||||
@@ -358,7 +356,7 @@ export function AgentMonitor() {
|
||||
</Badge>
|
||||
</div>
|
||||
<pre className="text-xs text-[var(--dg-text-secondary)] font-mono whitespace-pre-wrap break-all bg-[var(--dg-bg-primary)] border border-[var(--dg-border)] rounded-lg p-3 max-h-48 overflow-auto">
|
||||
{cmdResult.result || cmdResult.output || cmdResult.error || t('agent.agentmonitor.s26d45b')}
|
||||
{cmdResult.result || cmdResult.output || cmdResult.error || '无输出'}
|
||||
</pre>
|
||||
</div>
|
||||
)}
|
||||
@@ -374,9 +372,9 @@ export function AgentMonitor() {
|
||||
className="bg-blue-600 hover:bg-blue-700 text-white"
|
||||
>
|
||||
{cmdSubmitting ? (
|
||||
<><Loader2 className="h-4 w-4 mr-1.5 animate-spin" />{t('common.executing')}</>
|
||||
<><Loader2 className="h-4 w-4 mr-1.5 animate-spin" />执行中</>
|
||||
) : (
|
||||
<><Terminal className="h-4 w-4 mr-1.5" />{t('common.execute')}</>
|
||||
<><Terminal className="h-4 w-4 mr-1.5" />执行</>
|
||||
)}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
@@ -391,7 +389,6 @@ export function AgentMonitor() {
|
||||
|
||||
// ============ 指标条子组件 ============
|
||||
function MetricBar({ icon: Icon, label, value }: { icon: ComponentType<{ className?: string }>; label: string; value: number }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
<Icon className="h-3.5 w-3.5 dg-text-muted shrink-0" />
|
||||
|
||||
Reference in new issue
Block a user