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
e0072bcc
Commit
e0072bcc
authored
Jan 06, 2026
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:制度活化提问参数
parent
762d6fff
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
9 deletions
+41
-9
src/pages/Chat/Chat.tsx
+12
-3
src/pages/Home/HomeNew.tsx
+20
-1
src/store/conversationSlice.ts
+9
-5
No files found.
src/pages/Chat/Chat.tsx
View file @
e0072bcc
...
@@ -233,11 +233,16 @@ export const Chat: React.FC = () => {
...
@@ -233,11 +233,16 @@ export const Chat: React.FC = () => {
conversationId
:
currentIdRef
.
current
,
conversationId
:
currentIdRef
.
current
,
stream
:
true
,
stream
:
true
,
productCode
,
productCode
,
toolId
:
resolvedToolId
,
toolId
:
resolvedToolId
??
''
,
}
}
// 制度活化:toolId 为空字符串或 undefined
if
(
!
resolvedToolId
||
resolvedToolId
===
''
)
{
requestBody
.
toolId
=
''
requestBody
.
busiType
=
'01'
}
// 提质增效:toolId 为 6712395743241
// 提质增效:toolId 为 6712395743241
if
(
resolvedToolId
===
'6712395743241'
)
{
else
if
(
resolvedToolId
===
'6712395743241'
)
{
requestBody
.
busiType
=
'01'
requestBody
.
busiType
=
'01'
requestBody
.
recordType
=
'B00'
requestBody
.
recordType
=
'B00'
}
}
...
@@ -296,11 +301,15 @@ export const Chat: React.FC = () => {
...
@@ -296,11 +301,15 @@ export const Chat: React.FC = () => {
// 如果从收藏页返回,触发事件通知 HomeNew 刷新问题列表
// 如果从收藏页返回,触发事件通知 HomeNew 刷新问题列表
if
(
fromCollect
)
{
if
(
fromCollect
)
{
const
eventToolId
=
toolId
||
currentToolId
||
safeSessionStorageGetItem
(
'currentToolId'
)
||
''
console
.
log
(
'[Chat] 检测到从收藏页返回 (fromCollect=true) - 准备触发 refreshQuestionsFromCollect 事件'
)
console
.
log
(
'[Chat] refreshQuestionsFromCollect - 传递的 toolId:'
,
eventToolId
)
window
.
dispatchEvent
(
new
CustomEvent
(
'refreshQuestionsFromCollect'
,
{
window
.
dispatchEvent
(
new
CustomEvent
(
'refreshQuestionsFromCollect'
,
{
detail
:
{
detail
:
{
toolId
:
toolId
||
currentToolId
||
safeSessionStorageGetItem
(
'currentToolId'
)
||
''
,
toolId
:
eventToolId
,
},
},
}))
}))
console
.
log
(
'[Chat] refreshQuestionsFromCollect 事件已触发'
)
}
}
const
res
=
await
fetchUserQaRecordPage
(
conversationId
,
toolId
||
''
)
const
res
=
await
fetchUserQaRecordPage
(
conversationId
,
toolId
||
''
)
console
.
log
(
'qaRes chatEditor2222222'
,
res
)
console
.
log
(
'qaRes chatEditor2222222'
,
res
)
...
...
src/pages/Home/HomeNew.tsx
View file @
e0072bcc
...
@@ -111,6 +111,7 @@ export const Home: React.FC = () => {
...
@@ -111,6 +111,7 @@ export const Home: React.FC = () => {
// 刷新问题列表
// 刷新问题列表
const
handleRefreshQuestions
=
useCallback
(
async
()
=>
{
const
handleRefreshQuestions
=
useCallback
(
async
()
=>
{
console
.
log
(
'[HomeNew] handleRefreshQuestions 开始调用 - 刷新常见问题列表'
)
// 先清空旧数据
// 先清空旧数据
setOtherQuestions
((
prev
:
any
)
=>
({
setOtherQuestions
((
prev
:
any
)
=>
({
...
prev
,
...
prev
,
...
@@ -121,24 +122,32 @@ export const Home: React.FC = () => {
...
@@ -121,24 +122,32 @@ export const Home: React.FC = () => {
try
{
try
{
// 获取当前的 toolId,只从 sessionStorage 获取
// 获取当前的 toolId,只从 sessionStorage 获取
const
sessionToolId
=
safeSessionStorageGetItem
(
'currentToolId'
)
||
''
const
sessionToolId
=
safeSessionStorageGetItem
(
'currentToolId'
)
||
''
console
.
log
(
'[HomeNew] handleRefreshQuestions - 当前 toolId:'
,
sessionToolId
)
// 调用接口重新获取问题列表
// 调用接口重新获取问题列表
console
.
log
(
'[HomeNew] handleRefreshQuestions - 开始调用 fetchEfficiencyQuestionList 接口'
)
const
res
=
await
fetchEfficiencyQuestionList
({
const
res
=
await
fetchEfficiencyQuestionList
({
toolId
:
sessionToolId
,
toolId
:
sessionToolId
,
})
})
console
.
log
(
'[HomeNew] handleRefreshQuestions - fetchEfficiencyQuestionList 接口返回:'
,
res
)
if
(
res
&&
res
.
data
&&
res
.
data
.
questions
)
{
if
(
res
&&
res
.
data
&&
res
.
data
.
questions
)
{
console
.
log
(
'[HomeNew] handleRefreshQuestions - 获取到问题数量:'
,
res
.
data
.
questions
.
length
)
setOtherQuestions
((
prev
:
any
)
=>
({
setOtherQuestions
((
prev
:
any
)
=>
({
...
prev
,
...
prev
,
content
:
res
.
data
.
questions
||
[],
content
:
res
.
data
.
questions
||
[],
}))
}))
}
}
else
{
console
.
log
(
'[HomeNew] handleRefreshQuestions - 未获取到问题数据'
)
}
}
}
catch
(
error
)
{
catch
(
error
)
{
console
.
error
(
'刷新问题列表失败:'
,
error
)
console
.
error
(
'
[HomeNew] handleRefreshQuestions -
刷新问题列表失败:'
,
error
)
throw
error
// 抛出错误,让 QuestionList 组件处理
throw
error
// 抛出错误,让 QuestionList 组件处理
}
}
finally
{
finally
{
setIsDataLoaded
(
true
)
// 无论成功失败都标记为已加载
setIsDataLoaded
(
true
)
// 无论成功失败都标记为已加载
console
.
log
(
'[HomeNew] handleRefreshQuestions - 调用完成'
)
}
}
},
[
location
.
search
])
},
[
location
.
search
])
...
@@ -219,12 +228,16 @@ export const Home: React.FC = () => {
...
@@ -219,12 +228,16 @@ export const Home: React.FC = () => {
// 监听从收藏返回时刷新问题列表的事件
// 监听从收藏返回时刷新问题列表的事件
useEffect
(()
=>
{
useEffect
(()
=>
{
const
handleRefreshQuestionsFromCollect
=
(
event
:
CustomEvent
)
=>
{
const
handleRefreshQuestionsFromCollect
=
(
event
:
CustomEvent
)
=>
{
console
.
log
(
'[HomeNew] 监听到 refreshQuestionsFromCollect 事件 - 从收藏页面返回'
)
const
{
toolId
}
=
event
.
detail
const
{
toolId
}
=
event
.
detail
console
.
log
(
'[HomeNew] refreshQuestionsFromCollect - 接收到的 toolId:'
,
toolId
)
// 如果传递了 toolId,先更新 sessionStorage,确保刷新时使用正确的 toolId
// 如果传递了 toolId,先更新 sessionStorage,确保刷新时使用正确的 toolId
if
(
toolId
)
{
if
(
toolId
)
{
console
.
log
(
'[HomeNew] refreshQuestionsFromCollect - 更新 sessionStorage 中的 currentToolId:'
,
toolId
)
safeSessionStorageSetItem
(
'currentToolId'
,
toolId
)
safeSessionStorageSetItem
(
'currentToolId'
,
toolId
)
}
}
// 刷新问题列表,会调用 generate_question 接口
// 刷新问题列表,会调用 generate_question 接口
console
.
log
(
'[HomeNew] refreshQuestionsFromCollect - 开始调用 handleRefreshQuestions'
)
handleRefreshQuestions
()
handleRefreshQuestions
()
}
}
window
.
addEventListener
(
'refreshQuestionsFromCollect'
,
handleRefreshQuestionsFromCollect
as
EventListener
)
window
.
addEventListener
(
'refreshQuestionsFromCollect'
,
handleRefreshQuestionsFromCollect
as
EventListener
)
...
@@ -402,12 +415,18 @@ export const Home: React.FC = () => {
...
@@ -402,12 +415,18 @@ export const Home: React.FC = () => {
const
currentPath
=
location
.
pathname
const
currentPath
=
location
.
pathname
const
prevPath
=
prevPathRef
.
current
const
prevPath
=
prevPathRef
.
current
console
.
log
(
'[HomeNew] 路径变化检测 - 当前路径:'
,
currentPath
,
'上一路径:'
,
prevPath
)
// 检测从收藏页面返回到首页(避免首次挂载误触发)
// 检测从收藏页面返回到首页(避免首次挂载误触发)
if
(
prevPath
&&
prevPath
!==
currentPath
&&
prevPath
===
'/collect'
&&
(
currentPath
===
'/'
||
currentPath
===
'/home'
))
{
if
(
prevPath
&&
prevPath
!==
currentPath
&&
prevPath
===
'/collect'
&&
(
currentPath
===
'/'
||
currentPath
===
'/home'
))
{
console
.
log
(
'[HomeNew] 检测到从收藏页面返回 - 从 /collect 返回到首页'
)
// 确保已登录后再调用接口
// 确保已登录后再调用接口
if
(
token
)
{
if
(
token
)
{
console
.
log
(
'[HomeNew] 已登录,开始调用 handleRefreshQuestions'
)
handleRefreshQuestions
()
handleRefreshQuestions
()
}
}
else
{
console
.
log
(
'[HomeNew] 未登录,跳过刷新问题列表'
)
}
}
}
// 更新上一次路径
// 更新上一次路径
...
...
src/store/conversationSlice.ts
View file @
e0072bcc
...
@@ -62,12 +62,16 @@ export const createConversation = createAsyncThunk<
...
@@ -62,12 +62,16 @@ export const createConversation = createAsyncThunk<
{
state
:
{
conversation
:
ConversationState
}
}
{
state
:
{
conversation
:
ConversationState
}
}
>
(
>
(
'conversation/createConversation'
,
'conversation/createConversation'
,
async
({
conversationData
,
shouldNavigate
,
shouldSendQuestion
},
{
dispatch
,
getState
})
=>
{
async
({
conversationData
,
shouldNavigate
,
shouldSendQuestion
},
{
dispatch
})
=>
{
const
state
=
getState
()
// 从缓存中获取 toolId 作为 busiId
const
resolvedToolId
=
conversationData
.
toolId
??
state
.
conversation
.
currentToolId
const
cachedToolId
=
typeof
window
!==
'undefined'
?
sessionStorage
.
getItem
(
'currentToolId'
)
:
null
const
busiId
=
cachedToolId
||
''
// 排除 toolId 字段,只传递 busiId 和 busiType
const
{
toolId
,
...
restConversationData
}
=
conversationData
const
requestPayload
=
{
const
requestPayload
=
{
...
conversationData
,
...
restConversationData
,
...(
resolvedToolId
?
{
toolId
:
resolvedToolId
}
:
{}),
busiId
,
busiType
:
'01'
,
}
}
const
response
=
await
fetchCreateConversation
(
requestPayload
)
const
response
=
await
fetchCreateConversation
(
requestPayload
)
const
newConversation
=
response
.
data
const
newConversation
=
response
.
data
...
...
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