Add duplication assistant
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
|||||||
Boxes,
|
Boxes,
|
||||||
Brain,
|
Brain,
|
||||||
Check,
|
Check,
|
||||||
|
Copy,
|
||||||
Database,
|
Database,
|
||||||
MessageSquareText,
|
MessageSquareText,
|
||||||
MoreHorizontal,
|
MoreHorizontal,
|
||||||
@@ -296,6 +297,8 @@ export function AssistantPage() {
|
|||||||
voice: "晓宁",
|
voice: "晓宁",
|
||||||
enableInterrupt: true,
|
enableInterrupt: true,
|
||||||
});
|
});
|
||||||
|
const [assistants, setAssistants] =
|
||||||
|
useState<AssistantListItem[]>(mockAssistants);
|
||||||
const [view, setView] = useState<
|
const [view, setView] = useState<
|
||||||
| "list"
|
| "list"
|
||||||
| "choose"
|
| "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) {
|
if (typeFilter !== "全部" && assistant.type !== typeFilter) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -567,6 +597,13 @@ export function AssistantPage() {
|
|||||||
align="end"
|
align="end"
|
||||||
className="w-32 min-w-32 rounded-xl border border-hairline bg-popover p-1"
|
className="w-32 min-w-32 rounded-xl border border-hairline bg-popover p-1"
|
||||||
>
|
>
|
||||||
|
<DropdownMenuItem
|
||||||
|
className="rounded-lg"
|
||||||
|
onSelect={() => handleDuplicate(assistant)}
|
||||||
|
>
|
||||||
|
<Copy size={14} />
|
||||||
|
复制
|
||||||
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
variant="destructive"
|
variant="destructive"
|
||||||
className="rounded-lg"
|
className="rounded-lg"
|
||||||
|
|||||||
Reference in New Issue
Block a user