"use client" import { type ReactNode } from "react" import { Handle, Position } from "@xyflow/react" import { CheckCircle2, Loader2, AlertCircle } from "lucide-react" export type NodeKind = "input" | "process" | "ai" | "output" export type NodeStatus = "pending" | "running" | "done" | "failed" interface Props { type: NodeKind status: NodeStatus icon?: ReactNode title: string subtitle?: string width?: number selected?: boolean hasTarget?: boolean hasSource?: boolean children?: ReactNode } const STATUS_DOT: Record = { pending: "status-dot", running: "status-dot status-dot--running", done: "status-dot status-dot--done", failed: "status-dot status-dot--failed", } const STATUS_LABEL: Record = { pending: "待运行", running: "运行中", done: "完成", failed: "失败", } export function NodeShell({ type, status, icon, title, subtitle, width = 280, selected, hasTarget = true, hasSource = true, children, }: Props) { return (
{hasTarget && }
{icon ? {icon} : null} {title} {status === "running" ? : status === "done" ? : status === "failed" ? : null}
{subtitle && (
{subtitle} · {STATUS_LABEL[status]}
)} {children}
{hasSource && }
) }