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
396afeb0
Commit
396afeb0
authored
Dec 23, 2025
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 切换工具按钮时调用历史记录接口
parent
579b7852
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
+24
-3
src/api/conversation.ts
+2
-2
src/components/ChatEditor/index.tsx
+22
-1
No files found.
src/api/conversation.ts
View file @
396afeb0
...
@@ -20,8 +20,8 @@ export function fetchCreateConversation<T>(data: T) {
...
@@ -20,8 +20,8 @@ export function fetchCreateConversation<T>(data: T) {
* 查询用户问答历史
* 查询用户问答历史
* @params { * }
* @params { * }
*/
*/
export
function
fetchUserQaRecordPage
(
conversationId
:
string
)
{
export
function
fetchUserQaRecordPage
(
conversationId
:
string
,
toolId
?:
string
)
{
return
http
.
post
(
'/conversation/api/conversation/mobile/v1/query_user_qa_record_list'
,
{
conversationId
})
return
http
.
post
(
'/conversation/api/conversation/mobile/v1/query_user_qa_record_list'
,
{
conversationId
,
toolId
:
toolId
||
''
})
}
}
/**
/**
...
...
src/components/ChatEditor/index.tsx
View file @
396afeb0
...
@@ -2,7 +2,7 @@ import React, { useEffect, useRef, useState } from 'react'
...
@@ -2,7 +2,7 @@ import React, { useEffect, useRef, useState } from 'react'
import
{
AnimatePresence
,
motion
}
from
'framer-motion'
import
{
AnimatePresence
,
motion
}
from
'framer-motion'
import
{
Button
,
Tooltip
}
from
'@heroui/react'
import
{
Button
,
Tooltip
}
from
'@heroui/react'
import
{
useLocalStorageState
,
useToggle
}
from
'ahooks'
import
{
useLocalStorageState
,
useToggle
}
from
'ahooks'
import
{
useLocation
,
useSearchParams
}
from
'react-router-dom'
import
{
useLocation
,
use
Params
,
use
SearchParams
}
from
'react-router-dom'
import
{
LoginModal
}
from
'../LoginModal'
import
{
LoginModal
}
from
'../LoginModal'
import
type
{
RootState
}
from
'@/store'
import
type
{
RootState
}
from
'@/store'
import
SendIcon
from
'@/assets/svg/send.svg?react'
import
SendIcon
from
'@/assets/svg/send.svg?react'
...
@@ -10,6 +10,7 @@ import { type WithAuthProps, withAuth } from '@/auth/withAuth'
...
@@ -10,6 +10,7 @@ import { type WithAuthProps, withAuth } from '@/auth/withAuth'
import
{
useAppDispatch
,
useAppSelector
}
from
'@/store/hook'
import
{
useAppDispatch
,
useAppSelector
}
from
'@/store/hook'
import
{
clearCurrentToolId
,
setCurrentToolId
}
from
'@/store/conversationSlice'
import
{
clearCurrentToolId
,
setCurrentToolId
}
from
'@/store/conversationSlice'
import
{
fetchToolList
}
from
'@/api/home'
import
{
fetchToolList
}
from
'@/api/home'
import
{
fetchUserQaRecordPage
}
from
'@/api/conversation'
import
{
getUserRolesForApi
,
safeSessionStorageGetItem
,
safeSessionStorageRemoveItem
,
safeSessionStorageSetItem
}
from
'@/lib/utils'
import
{
getUserRolesForApi
,
safeSessionStorageGetItem
,
safeSessionStorageRemoveItem
,
safeSessionStorageSetItem
}
from
'@/lib/utils'
interface
ChatEditorProps
{
interface
ChatEditorProps
{
...
@@ -40,6 +41,7 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
...
@@ -40,6 +41,7 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
const
[
sessionToolId
,
setSessionToolId
]
=
useState
<
string
|
null
>
(
null
)
const
[
sessionToolId
,
setSessionToolId
]
=
useState
<
string
|
null
>
(
null
)
const
[
searchParams
,
setSearchParams
]
=
useSearchParams
()
const
[
searchParams
,
setSearchParams
]
=
useSearchParams
()
const
location
=
useLocation
()
const
location
=
useLocation
()
const
{
id
:
conversationId
}
=
useParams
<
{
id
:
string
}
>
()
const
toolIdFromUrl
=
searchParams
.
get
(
'toolId'
)
const
toolIdFromUrl
=
searchParams
.
get
(
'toolId'
)
const
fromCollect
=
location
.
state
?.
fromCollect
const
fromCollect
=
location
.
state
?.
fromCollect
...
@@ -235,6 +237,15 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
...
@@ -235,6 +237,15 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
newSearchParams
.
delete
(
'toolId'
)
newSearchParams
.
delete
(
'toolId'
)
setSearchParams
(
newSearchParams
,
{
replace
:
true
})
setSearchParams
(
newSearchParams
,
{
replace
:
true
})
}
}
// 调用接口
if
(
conversationId
)
{
try
{
await
fetchUserQaRecordPage
(
conversationId
,
''
)
}
catch
(
error
)
{
console
.
error
(
'获取问答记录失败:'
,
error
)
}
}
// try {
// try {
// await dispatch(createConversation({
// await dispatch(createConversation({
// conversationData: {},
// conversationData: {},
...
@@ -264,6 +275,16 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
...
@@ -264,6 +275,16 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
setSessionToolId
(
tool
.
toolId
)
setSessionToolId
(
tool
.
toolId
)
// 先通知上层更新欢迎语(即便后续接口异常也能生效)
// 先通知上层更新欢迎语(即便后续接口异常也能生效)
onToolClick
?.(
false
,
tool
.
toolId
,
tool
.
toolName
,
true
)
onToolClick
?.(
false
,
tool
.
toolId
,
tool
.
toolName
,
true
)
// 调用接口
if
(
conversationId
)
{
const
toolId
=
safeSessionStorageGetItem
(
'currentToolId'
)
||
''
try
{
await
fetchUserQaRecordPage
(
conversationId
,
toolId
)
}
catch
(
error
)
{
console
.
error
(
'获取问答记录失败:'
,
error
)
}
}
// try {
// try {
// await dispatch(createConversation({
// await dispatch(createConversation({
// conversationData: { toolId: tool.toolId },
// conversationData: { toolId: tool.toolId },
...
...
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