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
ca97a942
Commit
ca97a942
authored
Dec 01, 2025
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:常见问题悬浮展示所有文案
parent
e5d0da79
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
5 deletions
+64
-5
src/components/ChatEditor/index.tsx
+21
-0
src/layouts/HistoryBar/components/HistoryBarList/index.tsx
+9
-0
src/pages/Chat/Chat.tsx
+34
-5
No files found.
src/components/ChatEditor/index.tsx
View file @
ca97a942
...
...
@@ -79,11 +79,21 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
// 保持当前工具状态与 Redux 中的同步,确保跨页面返回时仍保持原模式
useEffect
(()
=>
{
// eslint-disable-next-line no-console
console
.
log
(
'[ChatEditor] currentToolId 变化:'
,
{
currentToolId
,
selectedToolId
,
isToolBtnActive
,
})
if
(
currentToolId
)
{
// eslint-disable-next-line no-console
console
.
log
(
'[ChatEditor] 设置 selectedToolId:'
,
currentToolId
)
setSelectedToolId
(
currentToolId
)
setIsToolBtnActive
(
false
)
}
else
{
// eslint-disable-next-line no-console
console
.
log
(
'[ChatEditor] 清除 selectedToolId,激活通用模式'
)
setSelectedToolId
(
null
)
setIsToolBtnActive
(
true
)
}
...
...
@@ -328,6 +338,17 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
{
toolList
.
map
((
tool
:
any
,
index
:
number
)
=>
{
// tool.toolName === '通用模式' 的按钮(通用模式)在默认状态下高亮
const
isSelected
=
(
selectedToolId
===
tool
.
toolId
)
||
(
tool
.
toolName
===
'通用模式'
&&
isToolBtnActive
)
// 调试打印
if
(
index
===
0
||
selectedToolId
===
tool
.
toolId
)
{
// eslint-disable-next-line no-console
console
.
log
(
'[ChatEditor] 按钮渲染:'
,
{
toolName
:
tool
.
toolName
,
toolId
:
tool
.
toolId
,
selectedToolId
,
isSelected
,
isToolBtnActive
,
})
}
const
buttonStyles
=
isSelected
?
{
backgroundColor
:
'#F3F7FF'
,
...
...
src/layouts/HistoryBar/components/HistoryBarList/index.tsx
View file @
ca97a942
...
...
@@ -26,10 +26,19 @@ export const HistoryBarList: React.FC<HistoryBarListProps> = ({ searchValue, onS
if
(
isMobile
())
{
onSetHistoryVisible
(
false
)
}
// eslint-disable-next-line no-console
console
.
log
(
'[HistoryBarList] 点击历史记录:'
,
{
conversationId
:
conversation
.
conversationId
,
toolId
:
conversation
.
toolId
,
})
if
(
conversation
.
toolId
)
{
// eslint-disable-next-line no-console
console
.
log
(
'[HistoryBarList] 设置 toolId 到 Redux:'
,
conversation
.
toolId
)
dispatch
(
setCurrentToolId
(
conversation
.
toolId
))
}
else
{
// eslint-disable-next-line no-console
console
.
log
(
'[HistoryBarList] 清除 toolId'
)
dispatch
(
clearCurrentToolId
())
}
// 直接导航到历史记录,不设置shouldSendQuestion
...
...
src/pages/Chat/Chat.tsx
View file @
ca97a942
...
...
@@ -206,6 +206,8 @@ export const Chat: React.FC = () => {
const
getUserQaRecordPage
=
useCallback
(
async
(
conversationId
:
string
)
=>
{
setIsLoading
(
true
)
try
{
// eslint-disable-next-line no-console
console
.
log
(
'[Chat] 开始获取历史记录:'
,
conversationId
)
const
res
=
await
fetchUserQaRecordPage
(
conversationId
)
const
qaRecords
=
res
.
data
||
[]
const
messages
=
[{
role
:
'system'
}
as
ChatRecord
,
...
processApiResponse
(
qaRecords
)]
...
...
@@ -228,22 +230,49 @@ export const Chat: React.FC = () => {
setAllItems
(
processedMessages
)
const
latestToolId
=
[...
qaRecords
].
reverse
().
find
(
item
=>
Boolean
(
item
.
toolId
))?.
toolId
?.
trim
?.()
const
hasQaRecords
=
qaRecords
.
length
>
0
// eslint-disable-next-line no-console
console
.
log
(
'[Chat] 从历史记录获取 toolId:'
,
{
conversationId
,
latestToolId
,
hasQaRecords
,
currentToolIdInRedux
:
currentToolId
,
})
// 优化:如果 Redux 中已有 toolId 且与历史记录中的一致,则不重复设置
// 这样可以避免覆盖 HistoryBarList 中设置的值
if
(
hasQaRecords
)
{
if
(
latestToolId
)
{
dispatch
(
setCurrentToolId
(
latestToolId
))
// 只有当 Redux 中的 toolId 与历史记录中的不一致时,才更新
if
(
currentToolId
!==
latestToolId
)
{
// eslint-disable-next-line no-console
console
.
log
(
'[Chat] 更新 toolId (不一致):'
,
{
from
:
currentToolId
,
to
:
latestToolId
,
})
dispatch
(
setCurrentToolId
(
latestToolId
))
}
else
{
// eslint-disable-next-line no-console
console
.
log
(
'[Chat] toolId 已一致,无需更新:'
,
latestToolId
)
}
}
else
{
dispatch
(
clearCurrentToolId
())
// 如果历史记录中没有 toolId,但 Redux 中有,需要清除
if
(
currentToolId
)
{
// eslint-disable-next-line no-console
console
.
log
(
'[Chat] 清除 toolId (历史记录中没有)'
)
dispatch
(
clearCurrentToolId
())
}
}
}
}
catch
{
catch
{
// 错误处理
}
finally
{
finally
{
setIsLoading
(
false
)
}
},
[
dispatch
])
},
[
dispatch
,
currentToolId
])
/** 点击滚动到底部 */
const
scrollToBottom
=
()
=>
{
...
...
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