Commit bcc6ee16 by Liu

fix:获取工具按钮列表去掉userRoles字段

parent eea71f34
......@@ -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)
}
......
......@@ -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(),
......
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