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
9a7cbc00
Commit
9a7cbc00
authored
Nov 27, 2025
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 工具部分逻辑
parent
5719d74e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
5 deletions
+15
-5
src/components/ChatEditor/index.tsx
+3
-3
src/layouts/HistoryBar/components/HistoryBarList/index.tsx
+0
-1
src/pages/Chat/Chat.tsx
+9
-1
src/pages/Chat/helper.ts
+1
-0
src/types/chat.ts
+2
-0
No files found.
src/components/ChatEditor/index.tsx
View file @
9a7cbc00
...
@@ -287,13 +287,13 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
...
@@ -287,13 +287,13 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
{
toolList
&&
toolList
.
length
>
0
&&
(
{
toolList
&&
toolList
.
length
>
0
&&
(
<
div
className=
"absolute left-4 bottom-2 flex items-center gap-3 pointer-events-auto pl-[16px]"
>
<
div
className=
"absolute left-4 bottom-2 flex items-center gap-3 pointer-events-auto pl-[16px]"
>
{
toolList
.
map
((
tool
:
any
,
index
:
number
)
=>
{
{
toolList
.
map
((
tool
:
any
,
index
:
number
)
=>
{
//
index === 1
的按钮(通用模式)在默认状态下高亮
//
tool.toolName === '通用模式'
的按钮(通用模式)在默认状态下高亮
const
isSelected
=
(
selectedToolId
===
tool
.
toolId
&&
!
isToolBtnActive
)
||
(
index
===
1
&&
isToolBtnActive
)
const
isSelected
=
(
selectedToolId
===
tool
.
toolId
&&
!
isToolBtnActive
)
||
(
tool
.
toolName
===
'通用模式'
&&
isToolBtnActive
)
const
handleButtonPress
=
async
()
=>
{
const
handleButtonPress
=
async
()
=>
{
// 高亮状态直接返回,避免重复触发
// 高亮状态直接返回,避免重复触发
if
(
isSelected
)
if
(
isSelected
)
return
return
if
(
index
===
1
)
if
(
tool
.
toolName
===
'通用模式'
)
await
handleGeneralClick
()
await
handleGeneralClick
()
else
else
await
handleToolClick
(
tool
)
await
handleToolClick
(
tool
)
...
...
src/layouts/HistoryBar/components/HistoryBarList/index.tsx
View file @
9a7cbc00
...
@@ -24,7 +24,6 @@ export const HistoryBarList: React.FC<HistoryBarListProps> = ({ searchValue, onS
...
@@ -24,7 +24,6 @@ export const HistoryBarList: React.FC<HistoryBarListProps> = ({ searchValue, onS
if
(
isMobile
())
{
if
(
isMobile
())
{
onSetHistoryVisible
(
false
)
onSetHistoryVisible
(
false
)
}
}
// 直接导航到历史记录,不设置shouldSendQuestion
// 直接导航到历史记录,不设置shouldSendQuestion
navigate
(
`/chat/
${
conversation
.
conversationId
}
`
)
navigate
(
`/chat/
${
conversation
.
conversationId
}
`
)
}
}
...
...
src/pages/Chat/Chat.tsx
View file @
9a7cbc00
...
@@ -233,6 +233,14 @@ export const Chat: React.FC = () => {
...
@@ -233,6 +233,14 @@ export const Chat: React.FC = () => {
return
item
return
item
})
})
setAllItems
(
processedMessages
)
setAllItems
(
processedMessages
)
const
latestToolRecord
=
[...
processedMessages
].
reverse
().
find
(
item
=>
item
.
role
===
'ai'
&&
item
.
toolId
!==
undefined
)
const
trimmedToolId
=
latestToolRecord
?.
toolId
?.
trim
?.()
if
(
trimmedToolId
)
{
dispatch
(
setCurrentToolId
(
trimmedToolId
))
}
else
{
dispatch
(
clearCurrentToolId
())
}
}
}
catch
{
catch
{
// 错误处理
// 错误处理
...
@@ -240,7 +248,7 @@ export const Chat: React.FC = () => {
...
@@ -240,7 +248,7 @@ export const Chat: React.FC = () => {
finally
{
finally
{
setIsLoading
(
false
)
setIsLoading
(
false
)
}
}
},
[])
},
[
dispatch
])
/** 点击滚动到底部 */
/** 点击滚动到底部 */
const
scrollToBottom
=
()
=>
{
const
scrollToBottom
=
()
=>
{
...
...
src/pages/Chat/helper.ts
View file @
9a7cbc00
...
@@ -18,6 +18,7 @@ export function processApiResponse(data: OriginalRecord[]): ChatRecord[] {
...
@@ -18,6 +18,7 @@ export function processApiResponse(data: OriginalRecord[]): ChatRecord[] {
role
:
'ai'
,
role
:
'ai'
,
answerList
:
record
.
answerList
,
answerList
:
record
.
answerList
,
question
:
record
.
question
,
question
:
record
.
question
,
toolId
:
record
.
toolId
,
})
})
}
}
})
})
...
...
src/types/chat.ts
View file @
9a7cbc00
...
@@ -45,6 +45,7 @@ export interface Answer {
...
@@ -45,6 +45,7 @@ export interface Answer {
conversationId
?:
string
conversationId
?:
string
terminateFlag
?:
boolean
terminateFlag
?:
boolean
toolName
?:
string
toolName
?:
string
toolId
?:
string
cardList
:
Attachment
[]
cardList
:
Attachment
[]
step
?:
AnswerStep
step
?:
AnswerStep
}
}
...
@@ -56,6 +57,7 @@ export interface OriginalRecord {
...
@@ -56,6 +57,7 @@ export interface OriginalRecord {
answerList
:
Answer
[]
answerList
:
Answer
[]
productCode
?:
string
productCode
?:
string
qaTime
?:
string
qaTime
?:
string
toolId
?:
string
}
}
export
type
ChatRecordRole
=
'system'
|
'user'
|
'ai'
export
type
ChatRecordRole
=
'system'
|
'user'
|
'ai'
...
...
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