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
bcc6ee16
Commit
bcc6ee16
authored
Apr 15, 2026
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:获取工具按钮列表去掉userRoles字段
parent
eea71f34
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
13 deletions
+8
-13
src/api/home.ts
+3
-6
src/components/ChatEditor/index.tsx
+5
-7
No files found.
src/api/home.ts
View file @
bcc6ee16
...
...
@@ -10,15 +10,12 @@ export function fetchQuestionList(data: any) {
/**
* 查询工具列表
* @params
params.userRoles: 角色数组,用于按角色返回工具
* @params
*/
export
function
fetchToolList
(
params
?:
{
userRoles
?:
string
[]
}
)
{
const
requestBody
:
Record
<
string
,
string
|
string
[]
>
=
{
export
function
fetchToolList
()
{
const
requestBody
:
Record
<
string
,
string
>
=
{
toolType
:
'03'
,
userRoles
:
[],
}
if
(
params
?.
userRoles
)
requestBody
.
userRoles
=
params
.
userRoles
return
http
.
post
(
'/config-center/api/tool/mobile/v1/get_tool_list'
,
requestBody
)
}
...
...
src/components/ChatEditor/index.tsx
View file @
bcc6ee16
...
...
@@ -11,7 +11,7 @@ import { useAppDispatch, useAppSelector } from '@/store/hook'
import
{
clearCurrentToolId
,
setCurrentToolId
}
from
'@/store/conversationSlice'
import
{
setIsAsking
}
from
'@/store/chatSlice'
import
{
fetchToolList
}
from
'@/api/home'
import
{
getUserRolesForApi
,
safeSessionStorageGetItem
,
safeSessionStorageRemoveItem
,
safeSessionStorageSetItem
}
from
'@/lib/utils'
import
{
safeSessionStorageGetItem
,
safeSessionStorageRemoveItem
,
safeSessionStorageSetItem
}
from
'@/lib/utils'
import
{
fetchSessionConversationId
,
fetchUserQaRecordPage
}
from
'@/api/conversation'
interface
ChatEditorProps
{
...
...
@@ -129,10 +129,8 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
try
{
// 等待 token 就绪后再调用接口
await
waitForToken
()
// 从路由中获取 userRoles 参数
const
userRoles
=
getUserRolesForApi
()
// 检查缓存(包含 userRoles 信息,有效期 5 分钟)
const
cacheKey
=
`toolList_
${
JSON
.
stringify
(
userRoles
)}
`
// 检查缓存(有效期 5 分钟)
const
cacheKey
=
'toolList'
const
cached
=
sessionStorage
.
getItem
(
cacheKey
)
if
(
cached
)
{
try
{
...
...
@@ -147,10 +145,10 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
}
}
// 调用真实 API 获取工具列表
const
res
=
await
fetchToolList
(
{
userRoles
}
)
const
res
=
await
fetchToolList
()
if
(
res
?.
data
&&
Array
.
isArray
(
res
.
data
)
&&
res
.
data
.
length
>
0
)
{
setToolList
(
res
.
data
)
// 缓存工具列表(包含
userRoles 和
时间戳)
// 缓存工具列表(包含时间戳)
sessionStorage
.
setItem
(
cacheKey
,
JSON
.
stringify
({
toolList
:
res
.
data
,
timestamp
:
Date
.
now
(),
...
...
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