import { useNavigate } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { ScrollArea } from '@/components/ui/scroll-area'; import { Rocket, AlertTriangle, ArrowRight, Cloud, Shield, Clock3, Globe, Database, Server, Monitor, Activity, } from 'lucide-react'; import { cn } from '@/lib/utils'; import type { AlertEventRecord, CertExpiryRecord } from '@/types'; /** 仪表盘卡片数据类型 — 与 Dashboard API 响应对齐 */ export interface DashboardRelease { id: number | string; status: string; app_name: string; version: string; environment?: string; commit_id?: string; [key: string]: unknown; } export interface DashboardCluster { id: number | string; code?: string; name: string; status: string; cpu_usage?: number; memory_usage?: number; node_count?: number; pod_count?: number; ingress_count?: number; deployment_count?: number; service_count?: number; [key: string]: unknown; } export interface DashboardAutomationStats { cron_job_count?: number; script_count?: number; today_executions?: number; success_rate?: number; } export interface DashboardOpsStats { domain_count?: number; site_task_count?: number; middleware_count?: number; snmp_device_count?: number; monitor_target_count?: number; } export interface DashboardPipelineStats { today_count?: number; success?: number; failed?: number; running?: number; } /** * DashboardRecent - 优化后的仪表盘底部卡片组件 * * 优化点: * 1. 使用 dg-card 工具类替代硬编码的 slate 颜色 * 2. 统一的状态指示器样式 * 3. 更好的 hover 效果和过渡动画 * 4. ScrollArea 使用 scrollbar-thin 类 * 5. 空状态显示更友好 */ // Status dot component function StatusDot({ severity }: { severity: string }) { return (
); } // Severity badge function SeverityBadge({ severity }: { severity: string }) { const { t } = useTranslation(); return ({t('dashboard.alerts.empty')}
{t('dashboard.alerts.emptyHint')}
{alert.target}
{alert.message}
{t('dashboard.certificates.empty')}
{domain.name}
{t('dashboard.certificates.expireDate')}: {domain.expire_date?.substring(0, 10)}
{t('dashboard.releases.empty')}
{t('dashboard.clusters.empty')}