Commit 0bdbb145 by Liu

fix:问候语逻辑

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