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
5719d74e
Commit
5719d74e
authored
Nov 27, 2025
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:路由拼接userRole区分权限
parent
704a4770
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
4 deletions
+18
-4
src/api/home.ts
+6
-3
src/components/ChatEditor/index.tsx
+12
-1
No files found.
src/api/home.ts
View file @
5719d74e
...
...
@@ -10,10 +10,13 @@ export function fetchQuestionList(data: any) {
/**
* 查询工具列表
* @params
* @params
params.userRole: 角色,用于按角色返回工具
*/
export
function
fetchToolList
()
{
return
http
.
post
(
'/config-center/api/tool/mobile/v1/get_tool_list'
,
{
toolType
:
'03'
})
export
function
fetchToolList
(
params
?:
{
userRole
?:
string
})
{
const
requestBody
:
Record
<
string
,
string
>
=
{
toolType
:
'03'
}
if
(
params
?.
userRole
)
requestBody
.
userRole
=
params
.
userRole
return
http
.
post
(
'/config-center/api/tool/mobile/v1/get_tool_list'
,
requestBody
)
}
/**
...
...
src/components/ChatEditor/index.tsx
View file @
5719d74e
...
...
@@ -10,6 +10,16 @@ import { useAppDispatch, useAppSelector } from '@/store/hook'
import
{
fetchToolList
}
from
'@/api/home'
import
{
createConversation
}
from
'@/store/conversationSlice'
function
getUserRoleFromRoute
()
{
try
{
const
searchParams
=
new
URLSearchParams
(
window
.
location
.
search
)
return
searchParams
.
get
(
'userRole'
)
||
undefined
}
catch
{
return
undefined
}
}
interface
ChatEditorProps
{
onChange
?:
(
value
:
string
)
=>
void
onFocus
?:
()
=>
void
...
...
@@ -37,7 +47,8 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
// 获取工具列表
const
getToolList
=
async
()
=>
{
try
{
const
res
=
await
fetchToolList
()
const
userRole
=
getUserRoleFromRoute
()
const
res
=
await
fetchToolList
(
userRole
?
{
userRole
}
:
undefined
)
if
(
res
?.
data
)
{
// 根据 toolId 去重,防止重复渲染
const
uniqueList
=
res
.
data
.
filter
((
tool
:
any
,
index
:
number
,
self
:
any
[])
=>
...
...
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