From b61a6015dbfaa0e215f450dee7c28542a43a18e9 Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Sat, 6 Jul 2024 18:11:18 +0800 Subject: [PATCH] feat: duplicate assistant --- .../src/pages/home/components/Assistants.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/pages/home/components/Assistants.tsx b/src/renderer/src/pages/home/components/Assistants.tsx index 947ffdb8..3479605d 100644 --- a/src/renderer/src/pages/home/components/Assistants.tsx +++ b/src/renderer/src/pages/home/components/Assistants.tsx @@ -5,7 +5,9 @@ import { Assistant } from '@renderer/types' import { Dropdown, MenuProps } from 'antd' import { last } from 'lodash' import AssistantSettingPopup from '@renderer/components/Popups/AssistantSettingPopup' -import { DeleteOutlined, EditOutlined } from '@ant-design/icons' +import { CopyOutlined, DeleteOutlined, EditOutlined } from '@ant-design/icons' +import { uuid } from '@renderer/utils' +import { getDefaultTopic } from '@renderer/services/assistant' interface Props { activeAssistant: Assistant @@ -14,7 +16,7 @@ interface Props { } const Assistants: FC = ({ activeAssistant, setActiveAssistant, onCreateAssistant }) => { - const { assistants, removeAssistant, updateAssistant } = useAssistants() + const { assistants, removeAssistant, updateAssistant, addAssistant } = useAssistants() const targetAssistant = useRef(null) const onDelete = (assistant: Assistant) => { @@ -37,6 +39,16 @@ const Assistants: FC = ({ activeAssistant, setActiveAssistant, onCreateAs } } }, + { + label: 'Duplicate', + key: 'duplicate', + icon: , + async onClick() { + const assistant: Assistant = { ...activeAssistant, id: uuid(), topics: [getDefaultTopic()] } + addAssistant(assistant) + setActiveAssistant(assistant) + } + }, { type: 'divider' }, { label: 'Delete',