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
e28c4017
Commit
e28c4017
authored
Feb 02, 2026
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:提质增效新建会话时逻辑
parent
18a982a3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
1 deletions
+34
-1
src/components/ChatEditor/index.tsx
+8
-1
src/pages/Chat/Chat.tsx
+26
-0
No files found.
src/components/ChatEditor/index.tsx
View file @
e28c4017
...
...
@@ -449,8 +449,13 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
qaRecords
:
qaRes
?.
data
||
[],
},
}))
// 提质增效模式下,获取会话ID后立即调用提问接口
// 提质增效模式下,延迟触发自动提问接口
// 使用双重 requestAnimationFrame 确保 Chat 组件的 currentIdRef 已经更新
if
(
tool
.
toolId
===
'6712395743241'
)
{
console
.
log
(
'[ChatEditor] 提质增效模式 - 准备延迟触发 autoSubmitQuestion'
,
{
conversationId
,
toolId
:
tool
.
toolId
})
requestAnimationFrame
(()
=>
{
requestAnimationFrame
(()
=>
{
console
.
log
(
'[ChatEditor] 提质增效模式 - 触发 autoSubmitQuestion 事件'
,
{
conversationId
,
toolId
:
tool
.
toolId
})
window
.
dispatchEvent
(
new
CustomEvent
(
'autoSubmitQuestion'
,
{
detail
:
{
conversationId
,
...
...
@@ -460,6 +465,8 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
busiType
:
'01'
,
},
}))
})
})
}
// 清除标记,避免影响后续路由切换
sessionStorage
.
removeItem
(
'toolHistoryLoading'
)
...
...
src/pages/Chat/Chat.tsx
View file @
e28c4017
...
...
@@ -262,6 +262,15 @@ export const Chat: React.FC = () => {
const
isEmptyQuestion
=
!
question
.
trim
()
const
isQualityImprovement
=
resolvedToolId
===
'6712395743241'
isAutoSubmitQualityImprovementRef
.
current
=
isEmptyQuestion
&&
isQualityImprovement
if
(
isAutoSubmitQualityImprovementRef
.
current
)
{
console
.
log
(
'[Chat] 提质增效自动调用 - handleSubmitQuestion 被调用'
,
{
question
,
resolvedToolId
,
conversationId
:
currentIdRef
.
current
,
isEmptyQuestion
,
isQualityImprovement
,
})
}
// 停止之前的请求
if
(
abortControllerRef
.
current
)
{
abortControllerRef
.
current
.
abort
()
...
...
@@ -750,6 +759,8 @@ export const Chat: React.FC = () => {
const
skipHistoryLoad
=
Boolean
((
location
.
state
as
{
skipHistoryLoad
?:
boolean
}
|
null
)?.
skipHistoryLoad
)
if
(
skipHistoryLoad
)
{
console
.
log
(
'[Chat] 检测到 skipHistoryLoad 标记,跳过历史记录加载,直接发送问题'
)
// 清空历史记录,只保留 system 记录(欢迎语)
setAllItems
([{
role
:
'system'
}
as
ChatRecord
])
currentIdRef
.
current
=
id
// 更新 toolId 相关状态(如果有)
if
(
initialToolId
!==
undefined
)
{
...
...
@@ -990,10 +1001,25 @@ export const Chat: React.FC = () => {
useEffect
(()
=>
{
const
handleAutoSubmitQuestion
=
(
event
:
CustomEvent
)
=>
{
const
{
conversationId
,
question
,
toolId
,
recordType
,
busiType
}
=
event
.
detail
console
.
log
(
'[Chat] 收到 autoSubmitQuestion 事件'
,
{
eventConversationId
:
conversationId
,
currentIdRef
:
currentIdRef
.
current
,
match
:
conversationId
===
currentIdRef
.
current
,
toolId
,
recordType
,
busiType
,
})
// 确保当前会话ID匹配
if
(
conversationId
===
currentIdRef
.
current
)
{
console
.
log
(
'[Chat] conversationId 匹配,调用 handleSubmitQuestion'
)
handleSubmitQuestion
(
question
,
undefined
,
toolId
,
{
recordType
,
busiType
})
}
else
{
console
.
warn
(
'[Chat] conversationId 不匹配,跳过自动提交'
,
{
eventConversationId
:
conversationId
,
currentIdRef
:
currentIdRef
.
current
,
})
}
}
window
.
addEventListener
(
'autoSubmitQuestion'
,
handleAutoSubmitQuestion
as
EventListener
)
return
()
=>
{
...
...
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