From 30f520ba0bf34b80b6b48c8d121366426b9bbfa5 Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Sat, 6 Jun 2026 07:29:23 +0800 Subject: [PATCH] Implement assistant type selection and creation flow in AssistantPage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added a new selection step for assistant types, allowing users to choose between different construction methods (提示词, 工作流, Dify, FastGPT) before creating an assistant. Enhanced the UI to display options with descriptions and icons, and updated the state management to handle the new view for selecting assistant types. This improves the user experience by guiding users through the assistant creation process. --- src/components/pages/AssistantPage.tsx | 258 ++++++++++++++++++++++++- 1 file changed, 256 insertions(+), 2 deletions(-) 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() { + + +
+ +
+ +
+
构建方式
+ +
+ {assistantTypeOptions.map((option) => { + const selected = draftType === option.type; + + return ( + + ); + })} +
+
+ +
+ + +
+ + ); + } + + if (view === "placeholder") { + const option = assistantTypeOptions.find( + (item) => item.type === draftType, + ); + + return ( +
+
+
+
+ {option?.label ?? "新建助手"} +
+

+ {draftName.trim() || "创建助手"} +

+

+ {draftType} 构建方式正在开发中,敬请期待。 +

+
+ + +
+ +
+
+
+
+
+ 建设中 +
+

+ {draftType} 构建页面正在编写中 +

+

+ 页面骨架与设计语言已就绪,后续将填充具体构建流程与数据。 +

+
+
+
+ ); + } + return (