import { memo } from 'react' import type { LucideIcon } from 'lucide-react' import { Card, CardContent } from '@/components/ui/card' import { cn } from '@/lib/utils' export interface ResourceField { label: string value: React.ReactNode /** 值提示(截断时 title) */ title?: string } interface ResourceCardProps { /** 头部图标 */ icon: LucideIcon /** 图标配色(text-info/success/warning 等语义 token 类) */ iconClassName?: string title: string /** 标题旁附加(如 ready 状态点、uuid) */ titleExtra?: React.ReactNode /** 右上角徽章(状态/保留天数等) */ badges?: React.ReactNode /** 副标题/描述(单行截断) */ description?: string /** 信息字段(两列网格;奇数个最后一项占整行) */ fields: ResourceField[] /** 底部状态消息(如错误信息,浅底块) */ message?: string /** 底部操作区(border-top 分隔) */ actions: React.ReactNode } /** * 资源卡片 — 五大资源页(集群/主机/存储/部署/采集)统一样式: * 图标+标题+徽章 → 描述 → 两列信息网格(label 上 value 下) → 分隔线操作区。 * 统一 p-4 内边距、hover 阴影、等高布局(网格内自动对齐)。 */ export const ResourceCard = memo(function ResourceCard({ icon: Icon, iconClassName = 'text-muted-foreground', title, titleExtra, badges, description, fields, message, actions, }: ResourceCardProps) { return ( {/* 头部:图标 + 标题 + 徽章 */}

{title}

{titleExtra} {badges && {badges}}
{description && (

{description}

)}
{/* 信息:两列网格(label 灰小字在上,value 在下) */}
{fields.map((f) => (

{f.label}

{f.value}

))}
{/* 状态消息(错误/提示) */} {message && (

{message}

)} {/* 操作区:贴底 */} {/* flex-wrap:按钮多时自动换行,避免在窄卡片里被 flex-1 压扁/溢出 */}
{actions}
) })