Commit 5719d74e by Liu

feat:路由拼接userRole区分权限

parent 704a4770
...@@ -10,10 +10,13 @@ export function fetchQuestionList(data: any) { ...@@ -10,10 +10,13 @@ export function fetchQuestionList(data: any) {
/** /**
* 查询工具列表 * 查询工具列表
* @params * @params params.userRole: 角色,用于按角色返回工具
*/ */
export function fetchToolList() { export function fetchToolList(params?: { userRole?: string }) {
return http.post('/config-center/api/tool/mobile/v1/get_tool_list', { toolType: '03' }) 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)
} }
/** /**
......
...@@ -10,6 +10,16 @@ import { useAppDispatch, useAppSelector } from '@/store/hook' ...@@ -10,6 +10,16 @@ import { useAppDispatch, useAppSelector } from '@/store/hook'
import { fetchToolList } from '@/api/home' import { fetchToolList } from '@/api/home'
import { createConversation } from '@/store/conversationSlice' 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 { interface ChatEditorProps {
onChange?: (value: string) => void onChange?: (value: string) => void
onFocus?: () => void onFocus?: () => void
...@@ -37,7 +47,8 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth, ...@@ -37,7 +47,8 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
// 获取工具列表 // 获取工具列表
const getToolList = async () => { const getToolList = async () => {
try { try {
const res = await fetchToolList() const userRole = getUserRoleFromRoute()
const res = await fetchToolList(userRole ? { userRole } : undefined)
if (res?.data) { if (res?.data) {
// 根据 toolId 去重,防止重复渲染 // 根据 toolId 去重,防止重复渲染
const uniqueList = res.data.filter((tool: any, index: number, self: any[]) => const uniqueList = res.data.filter((tool: any, index: number, self: any[]) =>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment