Commit 94303ad3 by Liu

fix:推荐问题增加toolId

parent 647bb115
......@@ -162,12 +162,15 @@ export function fetchGetFeedbackConfig() {
/**
* 查询推荐问题
* @param conversationId
* @param recordId
* @param toolId 可选的工具ID
* @returns Promise<any>
*/
export function fetchQueryRecommendQuestion(conversationId: string, recordId: string) {
export function fetchQueryRecommendQuestion(conversationId: string, recordId: string, toolId?: string) {
return http.post('/conversation/api/conversation/mobile/v1/query_recommend_question', {
conversationId,
recordId,
...(toolId ? { toolId } : {}),
})
}
......
......@@ -97,10 +97,20 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
// 根据 currentToolId 以及 sessionStorage 中的记录决定高亮逻辑
useEffect(() => {
// 场景:项目作为三方后台的子菜单时,外层可能清空了 sessionStorage,
// 但重新打开时仍使用带有 ?toolId=xxx 的旧 URL。
// 如果此时 Redux 和 sessionStorage 中都没有 currentToolId,则认为 URL 中的 toolId 已失效,
// 主动移除该查询参数并强制回到「通用模式」,避免错误高亮到上一次的工具模式。
if (currentToolId && !sessionToolId) {
// 清除过期的 Redux 值
dispatch(clearCurrentToolId())
// 如果 URL 中还有 toolId,也清除它
if (toolIdFromUrl) {
const newSearchParams = new URLSearchParams(searchParams)
newSearchParams.delete('toolId')
setSearchParams(newSearchParams, { replace: true })
}
setSelectedToolId(null)
setIsToolBtnActive(true)
return
}
if (!currentToolId && !sessionToolId && toolIdFromUrl) {
const newSearchParams = new URLSearchParams(searchParams)
newSearchParams.delete('toolId')
......@@ -225,8 +235,6 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
const handleGeneralClick = async () => {
if (!checkAuth())
return
// eslint-disable-next-line no-console
console.log('[ChatEditor] 点击通用模式按钮')
// 先更新 Redux,确保状态同步
dispatch(clearCurrentToolId())
// 立即更新本地状态,让 UI 立即响应
......@@ -259,11 +267,6 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
const handleToolClick = async (tool: any) => {
if (!checkAuth())
return
// eslint-disable-next-line no-console
console.log('[ChatEditor] 点击工具按钮:', {
toolId: tool.toolId,
toolName: tool.toolName,
})
if (tool.toolName === '数据助手') {
sessionStorage.setItem('showToolQuestion', 'true')
setShowToolQuestion(true)
......
......@@ -14,7 +14,13 @@ export const ChatAnswerRecommend: React.FC<ChatAnswerRecommendProps> = ({ answer
const [loading, setLoading] = useState<boolean>(false)
const getAnswerRecommend = async () => {
setLoading(true)
const res = await fetchQueryRecommendQuestion(answer.conversationId || '', answer.recordId || '')
// 从 sessionStorage 中获取 toolId
const toolId = typeof window !== 'undefined' ? sessionStorage.getItem('currentToolId') : null
const res = await fetchQueryRecommendQuestion(
answer.conversationId || '',
answer.recordId || '',
toolId || undefined,
)
if (res.ok) {
setQuestionList(res.data.questionList)
}
......
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