Commit 79258d30 by Liu

fix:图标改为base64

parent d920f8aa
......@@ -414,6 +414,19 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
await handleToolClick(tool)
}
// 处理后端返回的 base64 图标
const getToolIconSrc = () => {
if (!tool.toolIcon)
return ''
// 已经是完整的 dataURL,直接返回
if (typeof tool.toolIcon === 'string' && tool.toolIcon.startsWith('data:image'))
return tool.toolIcon
// 否则默认按 png 的纯 base64 拼接,如有需要可根据后端类型字段动态调整
return `data:image/png;base64,${tool.toolIcon}`
}
return (
<Button
key={tool.toolId || `tool-${index}`}
......@@ -425,7 +438,7 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
>
{tool.toolIcon && (
<img
src={tool.toolIcon}
src={getToolIconSrc()}
className="w-4 h-4 flex-shrink-0"
/>
)}
......
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