diff --git a/frontend/src/components/pages/AssistantPage.tsx b/frontend/src/components/pages/AssistantPage.tsx index e328ff2..97d7785 100644 --- a/frontend/src/components/pages/AssistantPage.tsx +++ b/frontend/src/components/pages/AssistantPage.tsx @@ -5,6 +5,7 @@ import { Boxes, Brain, Check, + Copy, Database, MessageSquareText, MoreHorizontal, @@ -296,6 +297,8 @@ export function AssistantPage() { voice: "晓宁", enableInterrupt: true, }); + const [assistants, setAssistants] = + useState(mockAssistants); const [view, setView] = useState< | "list" | "choose" @@ -369,7 +372,34 @@ export function AssistantPage() { } } - const filteredAssistants = mockAssistants.filter((assistant) => { + // 复制助手:在原助手之后插入一份拷贝,名称追加“副本”,并刷新更新时间 + function handleDuplicate(assistant: AssistantListItem) { + const now = new Date(); + const pad = (value: number) => String(value).padStart(2, "0"); + const timestamp = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad( + now.getDate(), + )} ${pad(now.getHours())}:${pad(now.getMinutes())}`; + + setAssistants((prev) => { + const index = prev.findIndex((item) => item.id === assistant.id); + const copy: AssistantListItem = { + id: `asst_${Date.now().toString().slice(-6)}`, + name: `${assistant.name} 副本`, + type: assistant.type, + updatedAt: timestamp, + }; + + if (index === -1) { + return [copy, ...prev]; + } + + const next = [...prev]; + next.splice(index + 1, 0, copy); + return next; + }); + } + + const filteredAssistants = assistants.filter((assistant) => { if (typeFilter !== "全部" && assistant.type !== typeFilter) { return false; } @@ -567,6 +597,13 @@ export function AssistantPage() { align="end" className="w-32 min-w-32 rounded-xl border border-hairline bg-popover p-1" > + handleDuplicate(assistant)} + > + + 复制 +