From 2676d61ccd9cb4fada8dac2bc9f512a10eaad25f Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Fri, 5 Jun 2026 21:52:07 +0800 Subject: [PATCH] Enhance AssistantPage with search functionality and UI improvements Added a search feature to filter assistants by name, type, or ID, improving user experience in managing assistants. Updated the layout and styling for better visual appeal, including new components for badges and dropdown menus. Removed deprecated status fields from mock data to streamline the assistant list display. --- src/components/pages/AssistantPage.tsx | 222 ++++++++++++++----------- 1 file changed, 127 insertions(+), 95 deletions(-) diff --git a/src/components/pages/AssistantPage.tsx b/src/components/pages/AssistantPage.tsx index ac27d6d..77f1327 100644 --- a/src/components/pages/AssistantPage.tsx +++ b/src/components/pages/AssistantPage.tsx @@ -3,23 +3,27 @@ import { Bot, Brain, - Database, Mic, MoreHorizontal, Pencil, Plus, Rocket, - Save, Search, Sparkles, Trash2, - Volume2, } from "lucide-react"; import { Button } from "@/components/ui/button"; +import { Badge } from "@/components/ui/badge"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { Switch } from "@/components/ui/switch"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; import { Select, SelectContent, @@ -53,7 +57,6 @@ type AssistantListItem = { id: string; name: string; type: AssistantType; - status: "运行中" | "草稿" | "已停用"; updatedAt: string; }; @@ -62,28 +65,24 @@ const mockAssistants: AssistantListItem[] = [ id: "asst_001", name: "政务视频咨询助手", type: "提示词", - status: "运行中", updatedAt: "2026-06-05 18:20", }, { id: "asst_002", name: "热线工单辅助助手", type: "工作流", - status: "草稿", updatedAt: "2026-06-04 15:12", }, { id: "asst_003", name: "Dify 知识库问答助手", type: "Dify", - status: "运行中", updatedAt: "2026-06-02 09:48", }, { id: "asst_004", name: "FastGPT 售后咨询助手", type: "FastGPT", - status: "已停用", updatedAt: "2026-05-29 11:06", }, ]; @@ -102,7 +101,20 @@ export function AssistantPage() { enableInterrupt: true, }); const [view, setView] = useState<"list" | "create">("list"); - const [openMenuId, setOpenMenuId] = useState(null); + const [searchQuery, setSearchQuery] = useState(""); + + const filteredAssistants = mockAssistants.filter((assistant) => { + const keyword = searchQuery.trim().toLowerCase(); + + if (!keyword) { + return true; + } + + return [assistant.name, assistant.id, assistant.type, assistant.updatedAt] + .join(" ") + .toLowerCase() + .includes(keyword); + }); function updateForm( key: K, @@ -115,117 +127,145 @@ export function AssistantPage() { } if (view === "list") { return ( -
-
+
+
-
- -

创建助手

-
-

+

助手管理
+

助手列表

+

管理已有的视频助手,支持提示词、工作流、Dify 和 FastGPT 类型。

- - +
- -
-
+ +
+
-
助手列表
-
+
+ 助手列表 +
+
共 {mockAssistants.length} 个助手 + {searchQuery.trim() && `,已筛选 ${filteredAssistants.length} 个`}
- -
- - 搜索助手名称... + +
+ + setSearchQuery(event.target.value)} + className="h-10 border-hairline-strong bg-background pl-9 text-sm text-foreground placeholder:text-muted-soft" + placeholder="搜索助手名称、类型或 ID..." + />
- -
-
-
助手名称
-
助手类型
-
状态
-
更新时间
-
操作
+ +
+
+
+ 助手名称 +
+
+ 助手类型 +
+
+ 更新时间 +
+
+ 操作 +
- -
- {mockAssistants.map((assistant) => ( + +
+ {filteredAssistants.map((assistant) => (
-
-
+
+
{assistant.name}
{assistant.id}
- -
- - {assistant.type} - -
- -
- + - {assistant.status} - + {assistant.type} +
- -
{assistant.updatedAt}
- -
- - - - - {openMenuId === assistant.id && ( -
- + + + + + + + 删除 - -
- )} + + +
))} + + {filteredAssistants.length === 0 && ( +
+
+ 未找到匹配的助手 +
+
+ 请调整关键词后再试。 +
+
+ )}
@@ -254,14 +294,6 @@ export function AssistantPage() { > 返回列表 -
); -} \ No newline at end of file +}