diff --git a/src/components/pages/AssistantPage.tsx b/src/components/pages/AssistantPage.tsx index 77f1327..89e4304 100644 --- a/src/components/pages/AssistantPage.tsx +++ b/src/components/pages/AssistantPage.tsx @@ -2,7 +2,11 @@ import { Bot, + Boxes, Brain, + Check, + Database, + MessageSquareText, Mic, MoreHorizontal, Pencil, @@ -11,6 +15,7 @@ import { Search, Sparkles, Trash2, + Workflow, } from "lucide-react"; import { Button } from "@/components/ui/button"; @@ -53,6 +58,46 @@ type AssistantForm = { type AssistantType = "提示词" | "工作流" | "Dify" | "FastGPT"; +type AssistantTypeOption = { + type: AssistantType; + label: string; + description: string; + icon: React.ReactNode; + /** 提示词类型已落地,其余三种暂时显示占位页 */ + available: boolean; +}; + +const assistantTypeOptions: AssistantTypeOption[] = [ + { + type: "提示词", + label: "使用提示词构建", + description: "通过提示词、模型与语音快速搭建对话助手,适合大多数场景。", + icon: , + available: true, + }, + { + type: "工作流", + label: "使用工作流构建", + description: "用可视化编排串联多个节点,适合多步骤、带分支的复杂流程。", + icon: , + available: false, + }, + { + type: "Dify", + label: "使用 Dify 构建", + description: "对接 Dify 应用,复用其编排能力与知识库配置。", + icon: , + available: false, + }, + { + type: "FastGPT", + label: "使用 FastGPT 构建", + description: "对接 FastGPT 应用,复用其知识库问答与工作流能力。", + icon: , + available: false, + }, +]; + type AssistantListItem = { id: string; name: string; @@ -100,8 +145,34 @@ export function AssistantPage() { knowledgeBase: "政务政策知识库", enableInterrupt: true, }); - const [view, setView] = useState<"list" | "create">("list"); + const [view, setView] = useState<"list" | "choose" | "create" | "placeholder">( + "list", + ); const [searchQuery, setSearchQuery] = useState(""); + // choose 步骤的草稿:名称与已选类型,确认后才决定进入哪个构建页 + const [draftName, setDraftName] = useState(""); + const [draftType, setDraftType] = useState(null); + + function startCreate() { + setDraftName(""); + setDraftType(null); + setView("choose"); + } + + function confirmType() { + if (!draftName.trim() || !draftType) { + return; + } + + if (draftType === "提示词") { + // 提示词类型:复用现有创建表单,并把已填的名称带过去 + updateForm("name", draftName.trim()); + setView("create"); + } else { + // 工作流 / Dify / FastGPT:暂时显示占位页 + setView("placeholder"); + } + } const filteredAssistants = mockAssistants.filter((assistant) => { const keyword = searchQuery.trim().toLowerCase(); @@ -140,7 +211,7 @@ export function AssistantPage() { setView("create")} + onClick={startCreate} > 创建助手 @@ -272,6 +343,189 @@ export function AssistantPage() { ); } + + if (view === "choose") { + const selectedOption = assistantTypeOptions.find( + (option) => option.type === draftType, + ); + + return ( + + + + 新建助手 + 创建助手 + + 先为助手取个名字,再选择构建方式。不同方式将进入不同的构建流程。 + + + + setView("list")} + > + 返回列表 + + + + + + + 助手名称 + + setDraftName(event.target.value)} + placeholder="请输入助手名称" + className="border-hairline-strong bg-background text-foreground placeholder:text-muted-soft" + /> + + + + + 构建方式 + + + {assistantTypeOptions.map((option) => { + const selected = draftType === option.type; + + return ( + setDraftType(option.type)} + className={`group relative flex flex-col gap-4 rounded-2xl border bg-card p-5 text-left transition-colors ${ + selected + ? "border-primary ring-1 ring-primary" + : "border-hairline hover:border-hairline-strong" + }`} + > + + + {option.icon} + + + {selected ? ( + + + + ) : ( + !option.available && ( + + 即将上线 + + ) + )} + + + + + {option.label} + + + {option.description} + + + + ); + })} + + + + + setView("list")} + > + 取消 + + + + {selectedOption && !selectedOption.available + ? "下一步" + : "开始构建"} + + + + ); + } + + if (view === "placeholder") { + const option = assistantTypeOptions.find( + (item) => item.type === draftType, + ); + + return ( + + + + + {option?.label ?? "新建助手"} + + + {draftName.trim() || "创建助手"} + + + {draftType} 构建方式正在开发中,敬请期待。 + + + + setView("list")} + > + 返回列表 + + + + + + + + + 建设中 + + + {draftType} 构建页面正在编写中 + + + 页面骨架与设计语言已就绪,后续将填充具体构建流程与数据。 + + + + + ); + } + return (
+ 先为助手取个名字,再选择构建方式。不同方式将进入不同的构建流程。 +
+ {option.description} +
+ {draftType} 构建方式正在开发中,敬请期待。 +
+ {draftType} 构建页面正在编写中 +
+ 页面骨架与设计语言已就绪,后续将填充具体构建流程与数据。 +