Commit 0bdbb145 by Liu

fix:问候语逻辑

parent 79258d30
...@@ -32,7 +32,7 @@ export const Chat: React.FC = () => { ...@@ -32,7 +32,7 @@ export const Chat: React.FC = () => {
const currentIdRef = useRef<string | undefined>(id) const currentIdRef = useRef<string | undefined>(id)
const lastSentQuestionRef = useRef<string>('') const lastSentQuestionRef = useRef<string>('')
const abortControllerRef = useRef<AbortController | null>(null) const abortControllerRef = useRef<AbortController | null>(null)
const [currentToolName, setCurrentToolName] = useState<string | undefined>(undefined) const [currentToolName, setCurrentToolName] = useState<string>('通用模式')
/** 处理正常stream的数据 */ /** 处理正常stream的数据 */
const handleStreamMesageData = (msg: any, question: string) => { const handleStreamMesageData = (msg: any, question: string) => {
...@@ -330,26 +330,23 @@ export const Chat: React.FC = () => { ...@@ -330,26 +330,23 @@ export const Chat: React.FC = () => {
// 根据 currentToolId 获取对应的 toolName // 根据 currentToolId 获取对应的 toolName
useEffect(() => { useEffect(() => {
if (!currentToolId)
return
const getToolNameFromToolId = async () => { const getToolNameFromToolId = async () => {
if (currentToolId) { try {
try { // 使用统一的方法获取 userRoles(先同步路由到 localStorage,然后读取)
// 使用统一的方法获取 userRoles(先同步路由到 localStorage,然后读取) const userRoles = getUserRolesForApi()
const userRoles = getUserRolesForApi() const res = await fetchToolList({ userRoles })
const res = await fetchToolList({ userRoles }) if (res?.data) {
if (res?.data) { const tool = res.data.find((t: any) => t.toolId === currentToolId)
const tool = res.data.find((t: any) => t.toolId === currentToolId) if (tool?.toolName) {
if (tool?.toolName) { setCurrentToolName(tool.toolName)
setCurrentToolName(tool.toolName)
}
} }
} }
catch (error) {
console.error('获取工具列表失败:', error)
}
} }
else { catch (error) {
// 通用模式 console.error('获取工具列表失败:', error)
setCurrentToolName('通用模式')
} }
} }
getToolNameFromToolId() getToolNameFromToolId()
......
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