|
|
|
@ -19,22 +19,27 @@ export const useToolIcon = (data: Node['data']) => {
|
|
|
|
const buildInTools = useStore(s => s.buildInTools)
|
|
|
|
const buildInTools = useStore(s => s.buildInTools)
|
|
|
|
const customTools = useStore(s => s.customTools)
|
|
|
|
const customTools = useStore(s => s.customTools)
|
|
|
|
const workflowTools = useStore(s => s.workflowTools)
|
|
|
|
const workflowTools = useStore(s => s.workflowTools)
|
|
|
|
|
|
|
|
const mcpTools = useStore(s => s.mcpTools)
|
|
|
|
const dataSourceList = useStore(s => s.dataSourceList)
|
|
|
|
const dataSourceList = useStore(s => s.dataSourceList)
|
|
|
|
// const a = useStore(s => s.data)
|
|
|
|
// const a = useStore(s => s.data)
|
|
|
|
const toolIcon = useMemo(() => {
|
|
|
|
const toolIcon = useMemo(() => {
|
|
|
|
|
|
|
|
if (!data)
|
|
|
|
|
|
|
|
return ''
|
|
|
|
if (data.type === BlockEnum.Tool) {
|
|
|
|
if (data.type === BlockEnum.Tool) {
|
|
|
|
let targetTools = buildInTools
|
|
|
|
let targetTools = buildInTools
|
|
|
|
if (data.provider_type === CollectionType.builtIn)
|
|
|
|
if (data.provider_type === CollectionType.builtIn)
|
|
|
|
targetTools = buildInTools
|
|
|
|
targetTools = buildInTools
|
|
|
|
else if (data.provider_type === CollectionType.custom)
|
|
|
|
else if (data.provider_type === CollectionType.custom)
|
|
|
|
targetTools = customTools
|
|
|
|
targetTools = customTools
|
|
|
|
|
|
|
|
else if (data.provider_type === CollectionType.mcp)
|
|
|
|
|
|
|
|
targetTools = mcpTools
|
|
|
|
else
|
|
|
|
else
|
|
|
|
targetTools = workflowTools
|
|
|
|
targetTools = workflowTools
|
|
|
|
return targetTools.find(toolWithProvider => canFindTool(toolWithProvider.id, data.provider_id))?.icon
|
|
|
|
return targetTools.find(toolWithProvider => canFindTool(toolWithProvider.id, data.provider_id))?.icon
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (data.type === BlockEnum.DataSource)
|
|
|
|
if (data.type === BlockEnum.DataSource)
|
|
|
|
return dataSourceList?.find(toolWithProvider => toolWithProvider.plugin_id === data.plugin_id)?.icon
|
|
|
|
return dataSourceList?.find(toolWithProvider => toolWithProvider.plugin_id === data.plugin_id)?.icon
|
|
|
|
}, [data, buildInTools, customTools, workflowTools, dataSourceList])
|
|
|
|
}, [data, dataSourceList, buildInTools, customTools, mcpTools, workflowTools])
|
|
|
|
|
|
|
|
|
|
|
|
return toolIcon
|
|
|
|
return toolIcon
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|