Commit 5098f0d7 by Liu

fix: 提质增效下新建会话后也需要自动调用提问接口

parent 256746af
...@@ -127,17 +127,22 @@ const NavbarBase: React.FC<NavbarProps & WithAuthProps> = ({ isHistoryVisible, c ...@@ -127,17 +127,22 @@ const NavbarBase: React.FC<NavbarProps & WithAuthProps> = ({ isHistoryVisible, c
? `/chat/${currentConversationId}?toolId=${currentToolId}` ? `/chat/${currentConversationId}?toolId=${currentToolId}`
: `/chat/${currentConversationId}` : `/chat/${currentConversationId}`
// 通过 location.state 传递 toolId,避免在 Chat 页面被误判为"外链残留参数"而强制清空 // 通过 location.state 传递 toolId,避免在 Chat 页面被误判为"外链残留参数"而强制清空
// 如果有 shouldSendQuestion,传递 skipHistoryLoad 标记,跳过历史记录加载 // 如果有 shouldSendQuestion 或者是提质增效模式,传递 skipHistoryLoad 标记,跳过历史记录加载
const isQualityImprovement = currentToolId === '6712395743241'
navigate(url, { navigate(url, {
state: { state: {
toolId: currentToolId || null, toolId: currentToolId || null,
skipHistoryLoad: Boolean(shouldSendQuestion), skipHistoryLoad: Boolean(shouldSendQuestion) || isQualityImprovement,
}, },
}) })
dispatch(clearNavigationFlag()) dispatch(clearNavigationFlag())
// 提质增效模式下,创建会话后自动调用提问接口(与 fetchSessionConversationId 后的逻辑保持一致) // 提质增效模式下,创建会话后自动调用提问接口(与 fetchSessionConversationId 后的逻辑保持一致)
if (currentToolId === '6712395743241') { // 使用 requestAnimationFrame 确保在下一个渲染周期执行,此时 Chat 组件已经挂载并且 currentIdRef.current 已经更新
if (isQualityImprovement) {
// 使用双重 requestAnimationFrame 确保在 DOM 更新后执行
requestAnimationFrame(() => {
requestAnimationFrame(() => {
window.dispatchEvent(new CustomEvent('autoSubmitQuestion', { window.dispatchEvent(new CustomEvent('autoSubmitQuestion', {
detail: { detail: {
conversationId: currentConversationId, conversationId: currentConversationId,
...@@ -147,6 +152,8 @@ const NavbarBase: React.FC<NavbarProps & WithAuthProps> = ({ isHistoryVisible, c ...@@ -147,6 +152,8 @@ const NavbarBase: React.FC<NavbarProps & WithAuthProps> = ({ isHistoryVisible, c
busiType: '01', busiType: '01',
}, },
})) }))
})
})
} }
} }
}, [shouldNavigateToNewConversation, currentConversationId, currentToolId, shouldSendQuestion, navigate, dispatch]) }, [shouldNavigateToNewConversation, currentConversationId, currentToolId, shouldSendQuestion, navigate, dispatch])
......
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