mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 12:37:20 +08:00
feat: tool selector get icon from marketplace
This commit is contained in:
parent
e3e8eafd32
commit
bb60db7078
@ -3,6 +3,7 @@ import Indicator from '@/app/components/header/indicator'
|
|||||||
import classNames from '@/utils/classnames'
|
import classNames from '@/utils/classnames'
|
||||||
import { memo, useMemo, useRef } from 'react'
|
import { memo, useMemo, useRef } from 'react'
|
||||||
import { useAllBuiltInTools, useAllCustomTools, useAllWorkflowTools } from '@/service/use-tools'
|
import { useAllBuiltInTools, useAllCustomTools, useAllWorkflowTools } from '@/service/use-tools'
|
||||||
|
import { getIconFromMarketPlace } from '@/utils/get-icon'
|
||||||
|
|
||||||
export type ToolIconProps = {
|
export type ToolIconProps = {
|
||||||
status?: 'error' | 'warning'
|
status?: 'error' | 'warning'
|
||||||
@ -23,6 +24,14 @@ export const ToolIcon = memo(({ status, tooltip, providerName }: ToolIconProps)
|
|||||||
return toolWithProvider.name === providerName
|
return toolWithProvider.name === providerName
|
||||||
})
|
})
|
||||||
}, [providerName, buildInTools, customTools, workflowTools])
|
}, [providerName, buildInTools, customTools, workflowTools])
|
||||||
|
const icon = useMemo(() => {
|
||||||
|
if (currentProvider) return currentProvider.icon as string
|
||||||
|
const providerNameParts = providerName.split('/')
|
||||||
|
const author = providerNameParts[0]
|
||||||
|
const name = providerNameParts[1]
|
||||||
|
const iconFromMarketPlace = getIconFromMarketPlace(`${author}/${name}`)
|
||||||
|
return iconFromMarketPlace
|
||||||
|
}, [currentProvider, providerName])
|
||||||
return <Tooltip triggerMethod='hover' popupContent={tooltip} disabled={!notSuccess}>
|
return <Tooltip triggerMethod='hover' popupContent={tooltip} disabled={!notSuccess}>
|
||||||
<div className={classNames(
|
<div className={classNames(
|
||||||
'size-5 border-[0.5px] border-components-panel-border-subtle bg-background-default-dodge relative flex items-center justify-center rounded-[6px]',
|
'size-5 border-[0.5px] border-components-panel-border-subtle bg-background-default-dodge relative flex items-center justify-center rounded-[6px]',
|
||||||
@ -31,7 +40,7 @@ export const ToolIcon = memo(({ status, tooltip, providerName }: ToolIconProps)
|
|||||||
>
|
>
|
||||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||||
<img
|
<img
|
||||||
src={currentProvider?.icon as string}
|
src={icon}
|
||||||
alt='tool icon'
|
alt='tool icon'
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'w-full h-full size-3.5 object-cover',
|
'w-full h-full size-3.5 object-cover',
|
||||||
|
|||||||
5
web/utils/get-icon.ts
Normal file
5
web/utils/get-icon.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { MARKETPLACE_API_PREFIX } from '@/config'
|
||||||
|
|
||||||
|
export const getIconFromMarketPlace = (plugin_id: string) => {
|
||||||
|
return `${MARKETPLACE_API_PREFIX}/plugins/${plugin_id}/icon`
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user