Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sdream-ai-fe
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
侯明涛
sdream-ai-fe
Commits
94303ad3
Commit
94303ad3
authored
Dec 03, 2025
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:推荐问题增加toolId
parent
647bb115
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
13 deletions
+25
-13
src/api/chat.ts
+4
-1
src/components/ChatEditor/index.tsx
+14
-11
src/pages/Chat/components/ChatItem/ChatAnswerRecommend.tsx
+7
-1
No files found.
src/api/chat.ts
View file @
94303ad3
...
@@ -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
}
:
{}),
})
})
}
}
...
...
src/components/ChatEditor/index.tsx
View file @
94303ad3
...
@@ -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
)
...
...
src/pages/Chat/components/ChatItem/ChatAnswerRecommend.tsx
View file @
94303ad3
...
@@ -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
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment