Commit 9a7cbc00 by Liu

feat: 工具部分逻辑

parent 5719d74e
......@@ -287,13 +287,13 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
{toolList && toolList.length > 0 && (
<div className="absolute left-4 bottom-2 flex items-center gap-3 pointer-events-auto pl-[16px]">
{toolList.map((tool: any, index: number) => {
// index === 1 的按钮(通用模式)在默认状态下高亮
const isSelected = (selectedToolId === tool.toolId && !isToolBtnActive) || (index === 1 && isToolBtnActive)
// tool.toolName === '通用模式' 的按钮(通用模式)在默认状态下高亮
const isSelected = (selectedToolId === tool.toolId && !isToolBtnActive) || (tool.toolName === '通用模式' && isToolBtnActive)
const handleButtonPress = async () => {
// 高亮状态直接返回,避免重复触发
if (isSelected)
return
if (index === 1)
if (tool.toolName === '通用模式')
await handleGeneralClick()
else
await handleToolClick(tool)
......
......@@ -24,7 +24,6 @@ export const HistoryBarList: React.FC<HistoryBarListProps> = ({ searchValue, onS
if (isMobile()) {
onSetHistoryVisible(false)
}
// 直接导航到历史记录,不设置shouldSendQuestion
navigate(`/chat/${conversation.conversationId}`)
}
......
......@@ -233,6 +233,14 @@ export const Chat: React.FC = () => {
return item
})
setAllItems(processedMessages)
const latestToolRecord = [...processedMessages].reverse().find(item => item.role === 'ai' && item.toolId !== undefined)
const trimmedToolId = latestToolRecord?.toolId?.trim?.()
if (trimmedToolId) {
dispatch(setCurrentToolId(trimmedToolId))
}
else {
dispatch(clearCurrentToolId())
}
}
catch {
// 错误处理
......@@ -240,7 +248,7 @@ export const Chat: React.FC = () => {
finally {
setIsLoading(false)
}
}, [])
}, [dispatch])
/** 点击滚动到底部 */
const scrollToBottom = () => {
......
......@@ -18,6 +18,7 @@ export function processApiResponse(data: OriginalRecord[]): ChatRecord[] {
role: 'ai',
answerList: record.answerList,
question: record.question,
toolId: record.toolId,
})
}
})
......
......@@ -45,6 +45,7 @@ export interface Answer {
conversationId?: string
terminateFlag?: boolean
toolName?: string
toolId?: string
cardList: Attachment[]
step?: AnswerStep
}
......@@ -56,6 +57,7 @@ export interface OriginalRecord {
answerList: Answer[]
productCode?: string
qaTime?: string
toolId?: string
}
export type ChatRecordRole = 'system' | 'user' | 'ai'
......
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