feat: add pin topic feature (#1408)
* feat: 新增导出至Notion的选项 * fix:添加多语言支持 * fix:添加提示语的多语言支持,以及防止重复导入的状态 * fix:修复多语言错误及调整UI样式统一 * feat:添加话题固定功能
This commit is contained in:
parent
bae76f921b
commit
220046cc95
@ -119,6 +119,8 @@
|
|||||||
"topics.export.notion": "Export to Notion",
|
"topics.export.notion": "Export to Notion",
|
||||||
"topics.export.md": "Export as markdown",
|
"topics.export.md": "Export as markdown",
|
||||||
"topics.export.title": "Export",
|
"topics.export.title": "Export",
|
||||||
|
"topics.pinned": "Pinned Topics",
|
||||||
|
"topics.unpinned": "Unpinned Topics",
|
||||||
"topics.export.word": "Export as Word",
|
"topics.export.word": "Export as Word",
|
||||||
"topics.list": "Topic List",
|
"topics.list": "Topic List",
|
||||||
"topics.move_to": "Move to",
|
"topics.move_to": "Move to",
|
||||||
|
|||||||
@ -117,6 +117,8 @@
|
|||||||
"topics.export.word": "Wordとしてエクスポート",
|
"topics.export.word": "Wordとしてエクスポート",
|
||||||
"topics.list": "トピックリスト",
|
"topics.list": "トピックリスト",
|
||||||
"topics.move_to": "移動先",
|
"topics.move_to": "移動先",
|
||||||
|
"topics.pinned": "トピックを固定",
|
||||||
|
"topics.unpinned": "固定解除",
|
||||||
"topics.title": "トピック",
|
"topics.title": "トピック",
|
||||||
"translate": "翻訳",
|
"translate": "翻訳",
|
||||||
"resend": "再送信",
|
"resend": "再送信",
|
||||||
|
|||||||
@ -117,6 +117,8 @@
|
|||||||
"topics.export.word": "Экспорт как Word",
|
"topics.export.word": "Экспорт как Word",
|
||||||
"topics.list": "Список топиков",
|
"topics.list": "Список топиков",
|
||||||
"topics.move_to": "Переместить в",
|
"topics.move_to": "Переместить в",
|
||||||
|
"topics.pinned": "Закрепленные темы",
|
||||||
|
"topics.unpinned": "Открепленные темы",
|
||||||
"topics.title": "Топики",
|
"topics.title": "Топики",
|
||||||
"translate": "Перевести",
|
"translate": "Перевести",
|
||||||
"resend": "Переотправить",
|
"resend": "Переотправить",
|
||||||
|
|||||||
@ -123,6 +123,8 @@
|
|||||||
"topics.list": "话题列表",
|
"topics.list": "话题列表",
|
||||||
"topics.move_to": "移动到",
|
"topics.move_to": "移动到",
|
||||||
"topics.title": "话题",
|
"topics.title": "话题",
|
||||||
|
"topics.pinned":"固定话题",
|
||||||
|
"topics.unpinned":"取消固定",
|
||||||
"translate": "翻译",
|
"translate": "翻译",
|
||||||
"resend": "重新发送",
|
"resend": "重新发送",
|
||||||
"thinking": "思考中",
|
"thinking": "思考中",
|
||||||
|
|||||||
@ -123,6 +123,8 @@
|
|||||||
"topics.list": "話題列表",
|
"topics.list": "話題列表",
|
||||||
"topics.move_to": "移動到",
|
"topics.move_to": "移動到",
|
||||||
"topics.title": "話題",
|
"topics.title": "話題",
|
||||||
|
"topics.pinned": "固定話題",
|
||||||
|
"topics.unpinned": "取消固定",
|
||||||
"translate": "翻譯",
|
"translate": "翻譯",
|
||||||
"resend": "重新發送",
|
"resend": "重新發送",
|
||||||
"thinking": "思考中",
|
"thinking": "思考中",
|
||||||
|
|||||||
@ -4,8 +4,8 @@ import {
|
|||||||
DeleteOutlined,
|
DeleteOutlined,
|
||||||
EditOutlined,
|
EditOutlined,
|
||||||
FolderOutlined,
|
FolderOutlined,
|
||||||
UploadOutlined
|
PushpinOutlined,
|
||||||
} from '@ant-design/icons'
|
UploadOutlined} from '@ant-design/icons'
|
||||||
import DragableList from '@renderer/components/DragableList'
|
import DragableList from '@renderer/components/DragableList'
|
||||||
import PromptPopup from '@renderer/components/Popups/PromptPopup'
|
import PromptPopup from '@renderer/components/Popups/PromptPopup'
|
||||||
import Scrollbar from '@renderer/components/Scrollbar'
|
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 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(
|
const onDeleteTopic = useCallback(
|
||||||
async (topic: Topic) => {
|
async (topic: Topic) => {
|
||||||
await modelGenerating()
|
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'),
|
label: t('chat.topics.clear.title'),
|
||||||
key: 'clear-messages',
|
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({ type: 'divider' })
|
||||||
menus.push({
|
menus.push({
|
||||||
label: t('common.delete'),
|
label: t('common.delete'),
|
||||||
@ -179,7 +195,7 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic
|
|||||||
|
|
||||||
return menus
|
return menus
|
||||||
},
|
},
|
||||||
[assistant, assistants, onClearMessages, onDeleteTopic, onMoveTopic, t, updateTopic]
|
[assistant, assistants, onClearMessages, onPinTopic, onDeleteTopic, onMoveTopic, t, updateTopic]
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -197,14 +213,15 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic
|
|||||||
{showTopicTime && (
|
{showTopicTime && (
|
||||||
<TopicTime className="time">{dayjs(topic.createdAt).format('MM/DD HH:mm')}</TopicTime>
|
<TopicTime className="time">{dayjs(topic.createdAt).format('MM/DD HH:mm')}</TopicTime>
|
||||||
)}
|
)}
|
||||||
{isActive && (
|
<MenuButton className="pin">{topic.pinned && <PushpinOutlined />}</MenuButton>
|
||||||
|
{isActive && !topic.pinned && (
|
||||||
<MenuButton
|
<MenuButton
|
||||||
className="menu"
|
className="menu"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
if (assistant.topics.length === 1) {
|
if (assistant.topics.length === 1) {
|
||||||
return onClearMessages()
|
return onClearMessages()
|
||||||
}
|
}
|
||||||
onDeleteTopic(topic)
|
onDeleteTopic(topic)
|
||||||
}}>
|
}}>
|
||||||
<CloseOutlined />
|
<CloseOutlined />
|
||||||
|
|||||||
@ -89,6 +89,7 @@ export type Topic = {
|
|||||||
createdAt: string
|
createdAt: string
|
||||||
updatedAt: string
|
updatedAt: string
|
||||||
messages: Message[]
|
messages: Message[]
|
||||||
|
pinned?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type User = {
|
export type User = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user