// DatasourceCard.tsx — 数据源卡片组件 // Logan.Li import { Check, X, Link, Pencil, Trash2, Loader2 } from 'lucide-react'; import { ENGINE_CONFIG } from './logLibraryTypes'; import type { LogDatasource } from './logLibraryTypes'; import { StatusDot } from './StatusDot'; interface DatasourceCardProps { ds: LogDatasource; onEdit: (ds: LogDatasource) => void; onDelete: (ds: LogDatasource) => void; onTest: (ds: LogDatasource) => void; testingId: number | null; testResult: { id: number; success: boolean; message: string } | null; } /** 单个数据源卡片:展示引擎、名称、URL、状态及操作按钮 */ export function DatasourceCard({ ds, onEdit, onDelete, onTest, testingId, testResult }: DatasourceCardProps) { const cfg = ENGINE_CONFIG[ds.engine]; const EngineIcon = cfg.icon; const isTesting = testingId === ds.id; const showResult = testResult?.id === ds.id; return (
{ (e.currentTarget as HTMLDivElement).style.boxShadow = '0 4px 12px rgba(0,0,0,0.15)'; }} onMouseLeave={(e) => { (e.currentTarget as HTMLDivElement).style.boxShadow = 'none'; }} > {/* 引擎色条 */}
{/* 头部:图标 + 名称 + 默认标记 */}
{ds.name} {ds.isDefault && ( 默认 )}
{cfg.label}
{/* URL */}
{ds.url}
{/* 描述 */} {ds.description && (
{ds.description}
)} {/* 状态行 + 操作按钮 */}
{/* 测试连接 */} {/* 编辑 */} {/* 删除 */}
{/* 测试结果提示 */} {showResult && (
{testResult.success ? : } {testResult.message}
)}
); }