feat: add pin topic feature (#1408)

* feat: 新增导出至Notion的选项

* fix:添加多语言支持

* fix:添加提示语的多语言支持,以及防止重复导入的状态

* fix:修复多语言错误及调整UI样式统一

* feat:添加话题固定功能
This commit is contained in:
Trey Dong 2025-02-11 16:51:58 +08:00 committed by GitHub
parent bae76f921b
commit 220046cc95
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 36 additions and 8 deletions

View File

@ -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",

View File

@ -117,6 +117,8 @@
"topics.export.word": "Wordとしてエクスポート",
"topics.list": "トピックリスト",
"topics.move_to": "移動先",
"topics.pinned": "トピックを固定",
"topics.unpinned": "固定解除",
"topics.title": "トピック",
"translate": "翻訳",
"resend": "再送信",

View File

@ -117,6 +117,8 @@
"topics.export.word": "Экспорт как Word",
"topics.list": "Список топиков",
"topics.move_to": "Переместить в",
"topics.pinned": "Закрепленные темы",
"topics.unpinned": "Открепленные темы",
"topics.title": "Топики",
"translate": "Перевести",
"resend": "Переотправить",

View File

@ -123,6 +123,8 @@
"topics.list": "话题列表",
"topics.move_to": "移动到",
"topics.title": "话题",
"topics.pinned":"固定话题",
"topics.unpinned":"取消固定",
"translate": "翻译",
"resend": "重新发送",
"thinking": "思考中",

View File

@ -123,6 +123,8 @@
"topics.list": "話題列表",
"topics.move_to": "移動到",
"topics.title": "話題",
"topics.pinned": "固定話題",
"topics.unpinned": "取消固定",
"translate": "翻譯",
"resend": "重新發送",
"thinking": "思考中",

View File

@ -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<Props> = ({ 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<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic
}
}
},
{
label: topic.pinned ? t('chat.topics.unpinned') : t('chat.topics.pinned'),
key: 'pin',
icon: <PushpinOutlined />,
onClick() {
onPinTopic(topic)
}
},
{
label: t('chat.topics.clear.title'),
key: 'clear-messages',
@ -166,7 +182,7 @@ const Topics: FC<Props> = ({ 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<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic
return menus
},
[assistant, assistants, onClearMessages, onDeleteTopic, onMoveTopic, t, updateTopic]
[assistant, assistants, onClearMessages, onPinTopic, onDeleteTopic, onMoveTopic, t, updateTopic]
)
return (
@ -197,7 +213,8 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic
{showTopicTime && (
<TopicTime className="time">{dayjs(topic.createdAt).format('MM/DD HH:mm')}</TopicTime>
)}
{isActive && (
<MenuButton className="pin">{topic.pinned && <PushpinOutlined />}</MenuButton>
{isActive && !topic.pinned && (
<MenuButton
className="menu"
onClick={(e) => {

View File

@ -89,6 +89,7 @@ export type Topic = {
createdAt: string
updatedAt: string
messages: Message[]
pinned?: boolean
}
export type User = {