From cd08f98bff50f7be40ce76db54317034fed8a1d6 Mon Sep 17 00:00:00 2001 From: AkaraChen Date: Thu, 26 Dec 2024 12:32:02 +0800 Subject: [PATCH 1/2] chore: upd app icon --- .../_base/components/agent-strategy-selector.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/web/app/components/workflow/nodes/_base/components/agent-strategy-selector.tsx b/web/app/components/workflow/nodes/_base/components/agent-strategy-selector.tsx index eca7fb30d8..136ddb27ee 100644 --- a/web/app/components/workflow/nodes/_base/components/agent-strategy-selector.tsx +++ b/web/app/components/workflow/nodes/_base/components/agent-strategy-selector.tsx @@ -15,6 +15,7 @@ import { useStrategyProviders } from '@/service/use-strategy' import type { StrategyPluginDetail } from '@/app/components/plugins/types' import type { ToolWithProvider } from '../../../types' import { CollectionType } from '@/app/components/tools/types' +import useGetIcon from '@/app/components/plugins/install-plugin/base/use-get-icon' const ExternalNotInstallWarn = () => { const { t } = useTranslation() @@ -82,15 +83,19 @@ export const AgentStrategySelector = (props: AgentStrategySelectorProps) => { }, [query, list]) // TODO: should be replaced by real data const isExternalInstalled = true + const { getIconUrl } = useGetIcon() + // TODO: 验证这玩意写对了没 + const iconFilename = list?.find( + coll => coll.tools?.find(tool => tool.name === value?.agent_strategy_name), + )?.icon + const icon = iconFilename ? getIconUrl(iconFilename as string) : undefined const { t } = useTranslation() return
setOpen(o => !o)}> {/* eslint-disable-next-line @next/next/no-img-element */} - {list && value && coll.tools?.find(tool => tool.name === value.agent_strategy_name), - )?.icon as string} + {icon && Date: Thu, 26 Dec 2024 12:41:44 +0800 Subject: [PATCH 2/2] fix: no icon in tool select --- .../_base/components/agent-strategy-selector.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/web/app/components/workflow/nodes/_base/components/agent-strategy-selector.tsx b/web/app/components/workflow/nodes/_base/components/agent-strategy-selector.tsx index 136ddb27ee..2e907ad1ad 100644 --- a/web/app/components/workflow/nodes/_base/components/agent-strategy-selector.tsx +++ b/web/app/components/workflow/nodes/_base/components/agent-strategy-selector.tsx @@ -35,7 +35,7 @@ const ExternalNotInstallWarn = () => { } -function formatStrategy(input: StrategyPluginDetail[]): ToolWithProvider[] { +function formatStrategy(input: StrategyPluginDetail[], getIcon: (i: string) => string): ToolWithProvider[] { return input.map((item) => { const res: ToolWithProvider = { id: item.provider, @@ -44,7 +44,7 @@ function formatStrategy(input: StrategyPluginDetail[]): ToolWithProvider[] { name: item.declaration.identity.name, description: item.declaration.identity.description as any, plugin_id: item.plugin_id, - icon: item.declaration.identity.icon, + icon: getIcon(item.declaration.identity.icon), label: item.declaration.identity.label as any, type: CollectionType.all, tools: item.declaration.strategies.map(strategy => ({ @@ -76,19 +76,18 @@ export const AgentStrategySelector = (props: AgentStrategySelectorProps) => { const [viewType, setViewType] = useState(ViewType.flat) const [query, setQuery] = useState('') const stra = useStrategyProviders() - const list = stra.data ? formatStrategy(stra.data) : undefined + const { getIconUrl } = useGetIcon() + const list = stra.data ? formatStrategy(stra.data, getIconUrl) : undefined const filteredTools = useMemo(() => { if (!list) return [] return list.filter(tool => tool.name.toLowerCase().includes(query.toLowerCase())) }, [query, list]) // TODO: should be replaced by real data const isExternalInstalled = true - const { getIconUrl } = useGetIcon() // TODO: 验证这玩意写对了没 - const iconFilename = list?.find( + const icon = list?.find( coll => coll.tools?.find(tool => tool.name === value?.agent_strategy_name), - )?.icon - const icon = iconFilename ? getIconUrl(iconFilename as string) : undefined + )?.icon as string | undefined const { t } = useTranslation() return