Commit ca97a942 by Liu

fix:常见问题悬浮展示所有文案

parent e5d0da79
......@@ -79,11 +79,21 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
// 保持当前工具状态与 Redux 中的同步,确保跨页面返回时仍保持原模式
useEffect(() => {
// eslint-disable-next-line no-console
console.log('[ChatEditor] currentToolId 变化:', {
currentToolId,
selectedToolId,
isToolBtnActive,
})
if (currentToolId) {
// eslint-disable-next-line no-console
console.log('[ChatEditor] 设置 selectedToolId:', currentToolId)
setSelectedToolId(currentToolId)
setIsToolBtnActive(false)
}
else {
// eslint-disable-next-line no-console
console.log('[ChatEditor] 清除 selectedToolId,激活通用模式')
setSelectedToolId(null)
setIsToolBtnActive(true)
}
......@@ -328,6 +338,17 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
{toolList.map((tool: any, index: number) => {
// tool.toolName === '通用模式' 的按钮(通用模式)在默认状态下高亮
const isSelected = (selectedToolId === tool.toolId) || (tool.toolName === '通用模式' && isToolBtnActive)
// 调试打印
if (index === 0 || selectedToolId === tool.toolId) {
// eslint-disable-next-line no-console
console.log('[ChatEditor] 按钮渲染:', {
toolName: tool.toolName,
toolId: tool.toolId,
selectedToolId,
isSelected,
isToolBtnActive,
})
}
const buttonStyles = isSelected
? {
backgroundColor: '#F3F7FF',
......
......@@ -26,10 +26,19 @@ export const HistoryBarList: React.FC<HistoryBarListProps> = ({ searchValue, onS
if (isMobile()) {
onSetHistoryVisible(false)
}
// eslint-disable-next-line no-console
console.log('[HistoryBarList] 点击历史记录:', {
conversationId: conversation.conversationId,
toolId: conversation.toolId,
})
if (conversation.toolId) {
// eslint-disable-next-line no-console
console.log('[HistoryBarList] 设置 toolId 到 Redux:', conversation.toolId)
dispatch(setCurrentToolId(conversation.toolId))
}
else {
// eslint-disable-next-line no-console
console.log('[HistoryBarList] 清除 toolId')
dispatch(clearCurrentToolId())
}
// 直接导航到历史记录,不设置shouldSendQuestion
......
......@@ -206,6 +206,8 @@ export const Chat: React.FC = () => {
const getUserQaRecordPage = useCallback(async (conversationId: string) => {
setIsLoading(true)
try {
// eslint-disable-next-line no-console
console.log('[Chat] 开始获取历史记录:', conversationId)
const res = await fetchUserQaRecordPage(conversationId)
const qaRecords = res.data || []
const messages = [{ role: 'system' } as ChatRecord, ...processApiResponse(qaRecords)]
......@@ -228,22 +230,49 @@ export const Chat: React.FC = () => {
setAllItems(processedMessages)
const latestToolId = [...qaRecords].reverse().find(item => Boolean(item.toolId))?.toolId?.trim?.()
const hasQaRecords = qaRecords.length > 0
// eslint-disable-next-line no-console
console.log('[Chat] 从历史记录获取 toolId:', {
conversationId,
latestToolId,
hasQaRecords,
currentToolIdInRedux: currentToolId,
})
// 优化:如果 Redux 中已有 toolId 且与历史记录中的一致,则不重复设置
// 这样可以避免覆盖 HistoryBarList 中设置的值
if (hasQaRecords) {
if (latestToolId) {
dispatch(setCurrentToolId(latestToolId))
// 只有当 Redux 中的 toolId 与历史记录中的不一致时,才更新
if (currentToolId !== latestToolId) {
// eslint-disable-next-line no-console
console.log('[Chat] 更新 toolId (不一致):', {
from: currentToolId,
to: latestToolId,
})
dispatch(setCurrentToolId(latestToolId))
}
else {
// eslint-disable-next-line no-console
console.log('[Chat] toolId 已一致,无需更新:', latestToolId)
}
}
else {
dispatch(clearCurrentToolId())
// 如果历史记录中没有 toolId,但 Redux 中有,需要清除
if (currentToolId) {
// eslint-disable-next-line no-console
console.log('[Chat] 清除 toolId (历史记录中没有)')
dispatch(clearCurrentToolId())
}
}
}
}
catch {
catch {
// 错误处理
}
finally {
finally {
setIsLoading(false)
}
}, [dispatch])
}, [dispatch, currentToolId])
/** 点击滚动到底部 */
const scrollToBottom = () => {
......
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