fix: disabled switch topic while generating message
This commit is contained in:
parent
a5d6e2c5c5
commit
3f3b930819
@ -41,7 +41,8 @@ const resources = {
|
|||||||
'error.enter.model': 'Please select a model first',
|
'error.enter.model': 'Please select a model first',
|
||||||
'api.connection.failed': 'Connection failed',
|
'api.connection.failed': 'Connection failed',
|
||||||
'api.connection.success': 'Connection successful',
|
'api.connection.success': 'Connection successful',
|
||||||
'chat.completion.paused': 'Chat completion paused'
|
'chat.completion.paused': 'Chat completion paused',
|
||||||
|
'topics.switch.disabled': 'Switching topics is disabled while the assistant is generating'
|
||||||
},
|
},
|
||||||
assistant: {
|
assistant: {
|
||||||
'default.name': '😀 Default Assistant',
|
'default.name': '😀 Default Assistant',
|
||||||
@ -174,7 +175,8 @@ const resources = {
|
|||||||
'error.enter.model': '请选择一个模型',
|
'error.enter.model': '请选择一个模型',
|
||||||
'api.connection.failed': '连接失败',
|
'api.connection.failed': '连接失败',
|
||||||
'api.connection.success': '连接成功',
|
'api.connection.success': '连接成功',
|
||||||
'chat.completion.paused': '会话已停止'
|
'chat.completion.paused': '会话已停止',
|
||||||
|
'topics.switch.disabled': '模型回复完成后才能切换话题'
|
||||||
},
|
},
|
||||||
assistant: {
|
assistant: {
|
||||||
'default.name': '😃 默认助手 - Assistant',
|
'default.name': '😃 默认助手 - Assistant',
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import LocalStorage from '@renderer/services/storage'
|
|||||||
import { DragDropContext, Draggable, Droppable, DropResult } from '@hello-pangea/dnd'
|
import { DragDropContext, Draggable, Droppable, DropResult } from '@hello-pangea/dnd'
|
||||||
import { droppableReorder } from '@renderer/utils'
|
import { droppableReorder } from '@renderer/utils'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { useAppSelector } from '@renderer/store'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
assistant: Assistant
|
assistant: Assistant
|
||||||
@ -22,6 +23,7 @@ const Topics: FC<Props> = ({ assistant, activeTopic, setActiveTopic }) => {
|
|||||||
const { showRightSidebar } = useShowRightSidebar()
|
const { showRightSidebar } = useShowRightSidebar()
|
||||||
const { removeTopic, updateTopic, removeAllTopics, updateTopics } = useAssistant(assistant.id)
|
const { removeTopic, updateTopic, removeAllTopics, updateTopics } = useAssistant(assistant.id)
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
const generating = useAppSelector((state) => state.runtime.generating)
|
||||||
|
|
||||||
const getTopicMenuItems = (topic: Topic) => {
|
const getTopicMenuItems = (topic: Topic) => {
|
||||||
const menus: MenuProps['items'] = [
|
const menus: MenuProps['items'] = [
|
||||||
@ -82,6 +84,14 @@ const Topics: FC<Props> = ({ assistant, activeTopic, setActiveTopic }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onSwitchTopic = (topic: Topic) => {
|
||||||
|
if (generating) {
|
||||||
|
window.message.info({ content: t('message.topics.switch.disabled'), key: 'switch-topic' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setActiveTopic(topic)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container style={{ display: showRightSidebar ? 'block' : 'none' }}>
|
<Container style={{ display: showRightSidebar ? 'block' : 'none' }}>
|
||||||
<TopicTitle>
|
<TopicTitle>
|
||||||
@ -111,7 +121,7 @@ const Topics: FC<Props> = ({ assistant, activeTopic, setActiveTopic }) => {
|
|||||||
<Dropdown menu={{ items: getTopicMenuItems(topic) }} trigger={['contextMenu']} key={topic.id}>
|
<Dropdown menu={{ items: getTopicMenuItems(topic) }} trigger={['contextMenu']} key={topic.id}>
|
||||||
<TopicListItem
|
<TopicListItem
|
||||||
className={topic.id === activeTopic?.id ? 'active' : ''}
|
className={topic.id === activeTopic?.id ? 'active' : ''}
|
||||||
onClick={() => setActiveTopic(topic)}>
|
onClick={() => onSwitchTopic(topic)}>
|
||||||
{topic.name}
|
{topic.name}
|
||||||
</TopicListItem>
|
</TopicListItem>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user