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
7a462a27
Commit
7a462a27
authored
Dec 15, 2025
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 提问参数&&清空会话逻辑
parent
b4dc7dee
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
32 deletions
+50
-32
src/pages/Chat/Chat.module.less
+3
-2
src/pages/ChatTactics/TacticsChat.tsx
+43
-26
src/pages/ChatTactics/TacticsHome.tsx
+2
-2
src/routes/RouteChangeHandler.tsx
+2
-2
No files found.
src/pages/Chat/Chat.module.less
View file @
7a462a27
...
...
@@ -24,8 +24,9 @@
overflow: hidden;
}
.scrollable {
flex-direction: column;
align-items: stretch;
flex-direction: column-reverse;
align-items: center;
justify-content: flex-end;
display: flex;
overflow-x: hidden;
overflow-y: scroll;
...
...
src/pages/ChatTactics/TacticsChat.tsx
View file @
7a462a27
...
...
@@ -65,8 +65,8 @@ export const TacticsChat: React.FC = () => {
taskId
:
searchParams
.
get
(
'taskId'
)
||
undefined
,
pinBeginTime
:
searchParams
.
get
(
'pinBeginTime'
)
||
undefined
,
pinEndTime
:
searchParams
.
get
(
'pinEndTime'
)
||
undefined
,
partOrAll
:
searchParams
.
get
(
'partOrAll'
)
||
'all'
,
channel
:
searchParams
.
get
(
'channel'
)
||
'AIphone'
,
partOrAll
:
searchParams
.
get
(
'partOrAll'
)
||
undefined
,
channel
:
searchParams
.
get
(
'channel'
)
||
undefined
,
channelName
:
searchParams
.
get
(
'channelName'
)
||
undefined
,
}
},
[
searchParams
])
...
...
@@ -171,17 +171,24 @@ export const TacticsChat: React.FC = () => {
const
handleStreamMesageData
=
(
msg
:
any
,
question
:
string
)
=>
{
setAllItems
((
prevItems
)
=>
{
const
newItems
=
[...
prevItems
]
// 创建数组的浅拷贝
const
lastIndex
=
newItems
.
length
-
1
if
(
lastIndex
>=
0
)
{
// 从后往前找到最后一个 AI 项
let
lastAiIndex
=
-
1
for
(
let
i
=
newItems
.
length
-
1
;
i
>=
0
;
i
--
)
{
if
(
newItems
[
i
].
role
===
'ai'
)
{
lastAiIndex
=
i
break
}
}
if
(
lastAiIndex
>=
0
)
{
// 创建最后一项的新对象,合并现有数据和新的 answer
const
originalAnswer
=
(
newItems
[
lastIndex
].
answerList
?.[
0
]?.
answer
||
''
)
+
msg
.
content
.
data
.
answer
const
originalAnswer
=
(
newItems
[
last
Ai
Index
].
answerList
?.[
0
]?.
answer
||
''
)
+
msg
.
content
.
data
.
answer
// 移除所有括号及其内容
let
filteredAnswer
=
originalAnswer
.
replace
(
/
\([^
)
]
*
\)
/g
,
''
).
trim
()
// 去除 [参考文档《任意内容》 《任意内容》...] 格式的内容
filteredAnswer
=
filteredAnswer
.
replace
(
/
\[
参考文档
(?:
《
[^
》
]
*》
\s
*
)
+
\]
/g
,
''
).
trim
()
newItems
[
lastIndex
]
=
{
...
newItems
[
lastIndex
],
newItems
[
last
Ai
Index
]
=
{
...
newItems
[
last
Ai
Index
],
question
,
answerList
:
[
{
...
...
@@ -200,10 +207,17 @@ export const TacticsChat: React.FC = () => {
const
handleChatMaxCount
=
(
msg
:
any
,
question
:
string
)
=>
{
setAllItems
((
prevItems
)
=>
{
const
newItems
=
[...
prevItems
]
const
lastIndex
=
newItems
.
length
-
1
if
(
lastIndex
>=
0
)
{
newItems
[
lastIndex
]
=
{
...
newItems
[
lastIndex
],
// 从后往前找到最后一个 AI 项
let
lastAiIndex
=
-
1
for
(
let
i
=
newItems
.
length
-
1
;
i
>=
0
;
i
--
)
{
if
(
newItems
[
i
].
role
===
'ai'
)
{
lastAiIndex
=
i
break
}
}
if
(
lastAiIndex
>=
0
)
{
newItems
[
lastAiIndex
]
=
{
...
newItems
[
lastAiIndex
],
question
,
answerList
:
[
{
...
...
@@ -227,15 +241,6 @@ export const TacticsChat: React.FC = () => {
toolId
?:
string
,
extra
?:
{
busiType
?:
string
,
recordType
?:
string
,
includeQuestion
?:
boolean
},
)
=>
{
// eslint-disable-next-line no-console
console
.
log
(
'[TacticsChat] handleSubmitQuestion:start'
,
{
question
,
productCode
,
toolIdFromProp
:
toolId
,
sessionToolId
:
sessionStorage
.
getItem
(
'currentToolId'
),
currentId
:
currentIdRef
.
current
,
extra
,
})
// 优先读取缓存中的 toolId,再回退到传参
const
sessionToolId
=
sessionStorage
.
getItem
(
'currentToolId'
)
??
undefined
const
resolvedToolId
=
toolId
??
sessionToolId
??
undefined
...
...
@@ -249,9 +254,6 @@ export const TacticsChat: React.FC = () => {
// 检查token
await
fetchCheckTokenApi
()
// eslint-disable-next-line no-console
console
.
log
(
'[TacticsChat] handleSubmitQuestion:afterCheckToken'
,
{
currentId
:
currentIdRef
.
current
})
// 一次性添加用户问题和空的AI回答;如果不需要问题(自动触发场景),只添加 AI 占位
const
shouldIncludeQuestion
=
extra
?.
includeQuestion
!==
false
&&
!!
question
setAllItems
(
prevItems
=>
[
...
...
@@ -399,6 +401,15 @@ export const TacticsChat: React.FC = () => {
return
try
{
await
dispatch
(
deleteTacticsConversations
([
currentIdRef
.
current
])).
unwrap
()
// 停止正在进行的请求
if
(
abortControllerRef
.
current
)
{
abortControllerRef
.
current
.
abort
()
dispatch
(
setIsAsking
(
false
))
}
// 清空对话列表,只保留欢迎语
setAllItems
([{
role
:
'system'
}
as
ChatRecord
])
setHistoryDividerIndex
(
null
)
setHistoryDividerTime
(
null
)
dispatch
(
createTacticsConversation
({
conversationData
:
{},
...
...
@@ -413,8 +424,8 @@ export const TacticsChat: React.FC = () => {
},
[
dispatch
])
const
handleReanalyze
=
useCallback
(
async
()
=>
{
// 重新触发一次提问,
不携带 question
await
handleSubmitQuestion
(
undefined
,
undefined
,
undefined
,
{
includeQuestion
:
false
})
// 重新触发一次提问,
与首次自动调用保持一致:busiType 01 / recordType A02
await
handleSubmitQuestion
(
undefined
,
undefined
,
undefined
,
{
busiType
:
'01'
,
recordType
:
'A02'
,
includeQuestion
:
false
})
// 重新拉取会话列表,保持原有行为
await
dispatch
(
fetchTacticsConversations
())
if
(
currentIdRef
.
current
)
{
...
...
@@ -451,6 +462,12 @@ export const TacticsChat: React.FC = () => {
// 进入会话后自动触发一次提交(不带 question),busiType 01 / recordType A02
const
hasAutoSubmittedRef
=
useRef
(
false
)
useEffect
(()
=>
{
if
(
id
)
{
// 当 id 变化时,重置自动提交标志
hasAutoSubmittedRef
.
current
=
false
}
},
[
id
])
useEffect
(()
=>
{
if
(
currentIdRef
.
current
&&
!
isLoading
&&
!
hasAutoSubmittedRef
.
current
)
{
hasAutoSubmittedRef
.
current
=
true
handleSubmitQuestion
(
...
...
@@ -460,7 +477,7 @@ export const TacticsChat: React.FC = () => {
{
busiType
:
'01'
,
recordType
:
'A02'
,
includeQuestion
:
false
},
)
}
},
[
isLoading
,
handleSubmitQuestion
])
},
[
isLoading
,
handleSubmitQuestion
,
id
])
// 创建新会话成功后跳转到新会话页面
useEffect
(()
=>
{
...
...
src/pages/ChatTactics/TacticsHome.tsx
View file @
7a462a27
...
...
@@ -37,8 +37,8 @@ export const TacticsHome: React.FC = () => {
taskId
:
searchParams
.
get
(
'taskId'
)
||
undefined
,
pinBeginTime
:
searchParams
.
get
(
'pinBeginTime'
)
||
undefined
,
pinEndTime
:
searchParams
.
get
(
'pinEndTime'
)
||
undefined
,
partOrAll
:
searchParams
.
get
(
'partOrAll'
)
||
'all'
,
channel
:
searchParams
.
get
(
'channel'
)
||
'AIphone'
,
partOrAll
:
searchParams
.
get
(
'partOrAll'
)
||
undefined
,
channel
:
searchParams
.
get
(
'channel'
)
||
undefined
,
channelName
:
searchParams
.
get
(
'channelName'
)
||
undefined
,
}
},
[
searchParams
])
...
...
src/routes/RouteChangeHandler.tsx
View file @
7a462a27
...
...
@@ -30,8 +30,8 @@ export function withRouteChangeHandler(WrappedComponent: React.ComponentType) {
taskId
:
searchParams
.
get
(
'taskId'
)
||
undefined
,
pinBeginTime
:
searchParams
.
get
(
'pinBeginTime'
)
||
undefined
,
pinEndTime
:
searchParams
.
get
(
'pinEndTime'
)
||
undefined
,
partOrAll
:
searchParams
.
get
(
'partOrAll'
)
||
'all'
,
channel
:
searchParams
.
get
(
'channel'
)
||
'AIphone'
,
partOrAll
:
searchParams
.
get
(
'partOrAll'
)
||
undefined
,
channel
:
searchParams
.
get
(
'channel'
)
||
undefined
,
channelName
:
searchParams
.
get
(
'channelName'
)
||
undefined
,
from
,
}
...
...
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