Commit 94303ad3 by Liu

fix:推荐问题增加toolId

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