import { Card, Text, Group, Stack, Badge } from "@mantine/core"; import { IconCheck, IconAlertTriangle, IconX } from "@tabler/icons-react"; // 状态映射:颜色 + 图标 const healthMap = { activate: { color: "green", icon: IconCheck }, error: { color: "red", icon: IconX }, warning: { color: "yellow", icon: IconAlertTriangle }, inactive: { color: "gray", icon: IconX }, }; export default function NodeHealthCard({ node }) { if (!node || !node.health) return null; const items = Object.entries(node.health); // [['agent', 'activate'], ...] return ( 健康状态 {items.map(([component, status]) => { const { color, icon: Icon } = healthMap[status] || healthMap.inactive; return ( {/* 组件名 */} {component} {/* 状态标签 */} } variant="filled"> {status} ); })} ); }