2026-06-15 10:12:41 +08:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 工作流可视化编辑器。基于 @xyflow/react,样式套用 ai-video 设计 token。
|
|
|
|
|
*
|
2026-07-14 09:36:28 +08:00
|
|
|
* 工具栏:添加节点、工作流设置、动态变量。全局设置、节点、条件边编辑与调试预览
|
2026-07-13 16:13:27 +08:00
|
|
|
* 复用画布右半覆盖层。
|
2026-06-15 10:12:41 +08:00
|
|
|
* 节点目录来自后端 /api/node-types。数据通过 value/onChange 与外部 graph 同步。
|
|
|
|
|
*/
|
|
|
|
|
|
2026-07-14 12:59:41 +08:00
|
|
|
import { ReactFlowProvider } from "@xyflow/react";
|
2026-06-15 10:12:41 +08:00
|
|
|
import "@xyflow/react/dist/style.css";
|
2026-07-14 12:59:41 +08:00
|
|
|
import { Loader2 } from "lucide-react";
|
2026-06-15 10:12:41 +08:00
|
|
|
|
2026-07-14 12:59:41 +08:00
|
|
|
import { WorkflowCanvas } from "./WorkflowCanvas";
|
2026-06-15 10:12:41 +08:00
|
|
|
import { useNodeSpecs } from "./useNodeSpecs";
|
2026-07-14 12:59:41 +08:00
|
|
|
import type { WorkflowEditorProps } from "./types";
|
2026-06-15 10:12:41 +08:00
|
|
|
|
2026-07-14 12:59:41 +08:00
|
|
|
export type { ModelOption, WorkflowEditorProps, WorkflowSettings } from "./types";
|
2026-06-15 10:12:41 +08:00
|
|
|
|
|
|
|
|
export function WorkflowEditor(props: WorkflowEditorProps) {
|
|
|
|
|
const { byType, loading, error } = useNodeSpecs();
|
|
|
|
|
|
|
|
|
|
if (loading) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex h-full w-full items-center justify-center rounded-2xl border border-hairline bg-canvas-soft text-muted-foreground">
|
|
|
|
|
<Loader2 className="mr-2 animate-spin" size={18} />
|
|
|
|
|
正在加载节点目录…
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (error) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex h-full w-full items-center justify-center rounded-2xl border border-hairline bg-canvas-soft px-6 text-center text-sm text-destructive">
|
|
|
|
|
加载节点目录失败:{error}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<ReactFlowProvider>
|
2026-07-14 12:59:41 +08:00
|
|
|
<WorkflowCanvas {...props} specsByType={byType} />
|
2026-06-15 10:12:41 +08:00
|
|
|
</ReactFlowProvider>
|
|
|
|
|
);
|
|
|
|
|
}
|