Commit fb2b017f by Liu

delete:切换工具按钮时不新建会话

parent 9112f406
...@@ -8,7 +8,7 @@ import type { RootState } from '@/store' ...@@ -8,7 +8,7 @@ import type { RootState } from '@/store'
import SendIcon from '@/assets/svg/send.svg?react' import SendIcon from '@/assets/svg/send.svg?react'
import { type WithAuthProps, withAuth } from '@/auth/withAuth' import { type WithAuthProps, withAuth } from '@/auth/withAuth'
import { useAppDispatch, useAppSelector } from '@/store/hook' import { useAppDispatch, useAppSelector } from '@/store/hook'
import { clearCurrentToolId, createConversation, setCurrentToolId } from '@/store/conversationSlice' import { clearCurrentToolId, setCurrentToolId } from '@/store/conversationSlice'
import { fetchToolList } from '@/api/home' import { fetchToolList } from '@/api/home'
import { getUserRolesForApi, safeSessionStorageGetItem, safeSessionStorageRemoveItem, safeSessionStorageSetItem } from '@/lib/utils' import { getUserRolesForApi, safeSessionStorageGetItem, safeSessionStorageRemoveItem, safeSessionStorageSetItem } from '@/lib/utils'
...@@ -235,16 +235,16 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth, ...@@ -235,16 +235,16 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
newSearchParams.delete('toolId') newSearchParams.delete('toolId')
setSearchParams(newSearchParams, { replace: true }) setSearchParams(newSearchParams, { replace: true })
} }
try { // try {
await dispatch(createConversation({ // await dispatch(createConversation({
conversationData: {}, // conversationData: {},
shouldNavigate: true, // shouldNavigate: true,
shouldSendQuestion: '', // shouldSendQuestion: '',
})).unwrap() // })).unwrap()
} // }
catch (error) { // catch (error) {
console.error('创建会话失败:', error) // console.error('创建会话失败:', error)
} // }
} }
// 处理工具按钮点击:先创建新会话,再切换工具 // 处理工具按钮点击:先创建新会话,再切换工具
...@@ -264,16 +264,16 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth, ...@@ -264,16 +264,16 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
setSessionToolId(tool.toolId) setSessionToolId(tool.toolId)
// 先通知上层更新欢迎语(即便后续接口异常也能生效) // 先通知上层更新欢迎语(即便后续接口异常也能生效)
onToolClick?.(false, tool.toolId, tool.toolName, true) onToolClick?.(false, tool.toolId, tool.toolName, true)
try { // try {
await dispatch(createConversation({ // await dispatch(createConversation({
conversationData: { toolId: tool.toolId }, // conversationData: { toolId: tool.toolId },
shouldNavigate: true, // shouldNavigate: true,
shouldSendQuestion: '', // shouldSendQuestion: '',
})).unwrap() // })).unwrap()
} // }
catch (error) { // catch (error) {
console.error('创建会话失败:', error) // console.error('创建会话失败:', error)
} // }
} }
useEffect(() => { useEffect(() => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment