diff --git a/src/renderer/src/i18n/locales/en-us.json b/src/renderer/src/i18n/locales/en-us.json index 4baa36ec..97d3be10 100644 --- a/src/renderer/src/i18n/locales/en-us.json +++ b/src/renderer/src/i18n/locales/en-us.json @@ -119,6 +119,8 @@ "topics.export.notion": "Export to Notion", "topics.export.md": "Export as markdown", "topics.export.title": "Export", + "topics.pinned": "Pinned Topics", + "topics.unpinned": "Unpinned Topics", "topics.export.word": "Export as Word", "topics.list": "Topic List", "topics.move_to": "Move to", diff --git a/src/renderer/src/i18n/locales/ja-jp.json b/src/renderer/src/i18n/locales/ja-jp.json index 8d1b136f..9dc709a3 100644 --- a/src/renderer/src/i18n/locales/ja-jp.json +++ b/src/renderer/src/i18n/locales/ja-jp.json @@ -117,6 +117,8 @@ "topics.export.word": "Wordとしてエクスポート", "topics.list": "トピックリスト", "topics.move_to": "移動先", + "topics.pinned": "トピックを固定", + "topics.unpinned": "固定解除", "topics.title": "トピック", "translate": "翻訳", "resend": "再送信", diff --git a/src/renderer/src/i18n/locales/ru-ru.json b/src/renderer/src/i18n/locales/ru-ru.json index df162710..ae8550d9 100644 --- a/src/renderer/src/i18n/locales/ru-ru.json +++ b/src/renderer/src/i18n/locales/ru-ru.json @@ -117,6 +117,8 @@ "topics.export.word": "Экспорт как Word", "topics.list": "Список топиков", "topics.move_to": "Переместить в", + "topics.pinned": "Закрепленные темы", + "topics.unpinned": "Открепленные темы", "topics.title": "Топики", "translate": "Перевести", "resend": "Переотправить", diff --git a/src/renderer/src/i18n/locales/zh-cn.json b/src/renderer/src/i18n/locales/zh-cn.json index be84485c..b53eee1d 100644 --- a/src/renderer/src/i18n/locales/zh-cn.json +++ b/src/renderer/src/i18n/locales/zh-cn.json @@ -123,6 +123,8 @@ "topics.list": "话题列表", "topics.move_to": "移动到", "topics.title": "话题", + "topics.pinned":"固定话题", + "topics.unpinned":"取消固定", "translate": "翻译", "resend": "重新发送", "thinking": "思考中", diff --git a/src/renderer/src/i18n/locales/zh-tw.json b/src/renderer/src/i18n/locales/zh-tw.json index 7cebe4ac..c7a96174 100644 --- a/src/renderer/src/i18n/locales/zh-tw.json +++ b/src/renderer/src/i18n/locales/zh-tw.json @@ -123,6 +123,8 @@ "topics.list": "話題列表", "topics.move_to": "移動到", "topics.title": "話題", + "topics.pinned": "固定話題", + "topics.unpinned": "取消固定", "translate": "翻譯", "resend": "重新發送", "thinking": "思考中", diff --git a/src/renderer/src/pages/home/Tabs/TopicsTab.tsx b/src/renderer/src/pages/home/Tabs/TopicsTab.tsx index 1dfeb435..d3338e1c 100644 --- a/src/renderer/src/pages/home/Tabs/TopicsTab.tsx +++ b/src/renderer/src/pages/home/Tabs/TopicsTab.tsx @@ -4,8 +4,8 @@ import { DeleteOutlined, EditOutlined, FolderOutlined, - UploadOutlined -} from '@ant-design/icons' + PushpinOutlined, + UploadOutlined} from '@ant-design/icons' import DragableList from '@renderer/components/DragableList' import PromptPopup from '@renderer/components/Popups/PromptPopup' import Scrollbar from '@renderer/components/Scrollbar' @@ -40,6 +40,14 @@ const Topics: FC = ({ assistant: _assistant, activeTopic, setActiveTopic const borderRadius = showTopicTime ? 12 : 'var(--list-item-border-radius)' + const onPinTopic = useCallback( + (topic: Topic) => { + const updatedTopic = { ...topic, pinned: !topic.pinned } + updateTopic(updatedTopic) + }, + [updateTopic] + ) + const onDeleteTopic = useCallback( async (topic: Topic) => { await modelGenerating() @@ -106,6 +114,14 @@ const Topics: FC = ({ assistant: _assistant, activeTopic, setActiveTopic } } }, + { + label: topic.pinned ? t('chat.topics.unpinned') : t('chat.topics.pinned'), + key: 'pin', + icon: , + onClick() { + onPinTopic(topic) + } + }, { label: t('chat.topics.clear.title'), key: 'clear-messages', @@ -166,7 +182,7 @@ const Topics: FC = ({ assistant: _assistant, activeTopic, setActiveTopic }) } - if (assistant.topics.length > 1) { + if (assistant.topics.length > 1 && !topic.pinned) { menus.push({ type: 'divider' }) menus.push({ label: t('common.delete'), @@ -179,7 +195,7 @@ const Topics: FC = ({ assistant: _assistant, activeTopic, setActiveTopic return menus }, - [assistant, assistants, onClearMessages, onDeleteTopic, onMoveTopic, t, updateTopic] + [assistant, assistants, onClearMessages, onPinTopic, onDeleteTopic, onMoveTopic, t, updateTopic] ) return ( @@ -197,14 +213,15 @@ const Topics: FC = ({ assistant: _assistant, activeTopic, setActiveTopic {showTopicTime && ( {dayjs(topic.createdAt).format('MM/DD HH:mm')} )} - {isActive && ( + {topic.pinned && } + {isActive && !topic.pinned && ( { e.stopPropagation() - if (assistant.topics.length === 1) { - return onClearMessages() - } + if (assistant.topics.length === 1) { + return onClearMessages() + } onDeleteTopic(topic) }}> diff --git a/src/renderer/src/types/index.ts b/src/renderer/src/types/index.ts index 978411aa..f58dacf5 100644 --- a/src/renderer/src/types/index.ts +++ b/src/renderer/src/types/index.ts @@ -89,6 +89,7 @@ export type Topic = { createdAt: string updatedAt: string messages: Message[] + pinned?: boolean } export type User = {