From 8b28ed589c91ae3e43b3a663fe6fb4b4ce73a343 Mon Sep 17 00:00:00 2001 From: nite-knite Date: Tue, 3 Dec 2024 13:43:13 +0800 Subject: [PATCH 1/2] feat: update translation for bundle --- web/i18n/zh-Hans/plugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/i18n/zh-Hans/plugin.ts b/web/i18n/zh-Hans/plugin.ts index f5232cecaa..b7d1678925 100644 --- a/web/i18n/zh-Hans/plugin.ts +++ b/web/i18n/zh-Hans/plugin.ts @@ -4,7 +4,7 @@ const translation = { models: '模型', tools: '工具', extensions: '扩展', - bundles: '捆绑包', + bundles: '插件集', }, search: '搜索', allCategories: '所有类别', From ab9a177c908f2c4f56ad54768e9b25502e6d27c8 Mon Sep 17 00:00:00 2001 From: StyleZhang Date: Tue, 3 Dec 2024 14:34:23 +0800 Subject: [PATCH 2/2] fix: marketplace list --- .../model-provider-page/hooks.ts | 2 + web/app/components/plugins/card/index.tsx | 2 +- .../plugins/marketplace/context.tsx | 15 +++++- .../components/plugins/marketplace/hooks.ts | 9 ++-- .../plugins/marketplace/list/card-wrapper.tsx | 6 +-- .../components/plugins/marketplace/types.ts | 2 + .../components/plugins/marketplace/utils.ts | 47 +++++++++++++++++-- web/app/components/plugins/provider-card.tsx | 6 ++- web/app/components/plugins/types.ts | 1 + web/app/components/tools/marketplace/hooks.ts | 3 ++ web/service/use-plugins.ts | 2 + 11 files changed, 77 insertions(+), 18 deletions(-) diff --git a/web/app/components/header/account-setting/model-provider-page/hooks.ts b/web/app/components/header/account-setting/model-provider-page/hooks.ts index 7d1d2b6877..ab3e3e5593 100644 --- a/web/app/components/header/account-setting/model-provider-page/hooks.ts +++ b/web/app/components/header/account-setting/model-provider-page/hooks.ts @@ -264,6 +264,7 @@ export const useMarketplace = (providers: ModelProvider[], searchText: string) = query: searchText, category: PluginType.model, exclude, + type: 'plugin', }) } else { @@ -271,6 +272,7 @@ export const useMarketplace = (providers: ModelProvider[], searchText: string) = category: PluginType.model, condition: getMarketplaceListCondition(PluginType.model), exclude, + type: 'plugin', }) resetPlugins() } diff --git a/web/app/components/plugins/card/index.tsx b/web/app/components/plugins/card/index.tsx index 0d4cae9e89..06253aed7b 100644 --- a/web/app/components/plugins/card/index.tsx +++ b/web/app/components/plugins/card/index.tsx @@ -44,7 +44,7 @@ const Card = ({ const locale = localeFromProps ? getLanguage(localeFromProps) : defaultLocale const { categoriesMap } = useCategories() const { type, category, name, org, label, brief, icon, verified } = payload - const cornerMark = type !== 'plugin' ? type : categoriesMap[category]?.label + const cornerMark = type !== 'plugin' ? categoriesMap.bundle?.label : categoriesMap[category]?.label const getLocalizedText = (obj: Record | undefined) => obj?.[locale] || obj?.['en-US'] || obj?.en_US || '' diff --git a/web/app/components/plugins/marketplace/context.tsx b/web/app/components/plugins/marketplace/context.tsx index 57e3dae420..1579ab620d 100644 --- a/web/app/components/plugins/marketplace/context.tsx +++ b/web/app/components/plugins/marketplace/context.tsx @@ -30,7 +30,10 @@ import { useMarketplaceCollectionsAndPlugins, useMarketplacePlugins, } from './hooks' -import { getMarketplaceListCondition } from './utils' +import { + getMarketplaceListCondition, + getMarketplaceListFilterType, +} from './utils' import { useInstalledPluginList } from '@/service/use-plugins' export type MarketplaceContextValue = { @@ -60,7 +63,7 @@ export const MarketplaceContext = createContext({ handleSearchPluginTextChange: () => {}, filterPluginTags: [], handleFilterPluginTagsChange: () => {}, - activePluginType: PLUGIN_TYPE_SEARCH_MAP.all, + activePluginType: 'all', handleActivePluginTypeChange: () => {}, plugins: undefined, resetPlugins: () => {}, @@ -131,6 +134,7 @@ export const MarketplaceContextProvider = ({ tags: hasValidTags ? tagsFromSearchParams : [], sortBy: sortRef.current.sortBy, sortOrder: sortRef.current.sortOrder, + type: getMarketplaceListFilterType(activePluginTypeRef.current), }) history.pushState({}, '', `/${searchParams?.language ? `?language=${searchParams?.language}` : ''}`) } @@ -138,6 +142,7 @@ export const MarketplaceContextProvider = ({ if (shouldExclude && isSuccess) { queryMarketplaceCollectionsAndPlugins({ exclude, + type: getMarketplaceListFilterType(activePluginTypeRef.current), }) } } @@ -153,6 +158,7 @@ export const MarketplaceContextProvider = ({ category: activePluginTypeRef.current === PLUGIN_TYPE_SEARCH_MAP.all ? undefined : activePluginTypeRef.current, condition: getMarketplaceListCondition(activePluginTypeRef.current), exclude, + type: getMarketplaceListFilterType(activePluginTypeRef.current), }) resetPlugins() @@ -178,6 +184,7 @@ export const MarketplaceContextProvider = ({ category: activePluginTypeRef.current === PLUGIN_TYPE_SEARCH_MAP.all ? undefined : activePluginTypeRef.current, condition: getMarketplaceListCondition(activePluginTypeRef.current), exclude, + type: getMarketplaceListFilterType(activePluginTypeRef.current), }) resetPlugins() @@ -191,6 +198,7 @@ export const MarketplaceContextProvider = ({ sortBy: sortRef.current.sortBy, sortOrder: sortRef.current.sortOrder, exclude, + type: getMarketplaceListFilterType(activePluginTypeRef.current), }) }, [queryPlugins, resetPlugins, queryMarketplaceCollectionsAndPlugins, exclude]) @@ -203,6 +211,7 @@ export const MarketplaceContextProvider = ({ category: type === PLUGIN_TYPE_SEARCH_MAP.all ? undefined : type, condition: getMarketplaceListCondition(type), exclude, + type: getMarketplaceListFilterType(activePluginTypeRef.current), }) resetPlugins() @@ -216,6 +225,7 @@ export const MarketplaceContextProvider = ({ sortBy: sortRef.current.sortBy, sortOrder: sortRef.current.sortOrder, exclude, + type: getMarketplaceListFilterType(activePluginTypeRef.current), }) }, [queryPlugins, resetPlugins, queryMarketplaceCollectionsAndPlugins, exclude]) @@ -230,6 +240,7 @@ export const MarketplaceContextProvider = ({ sortBy: sortRef.current.sortBy, sortOrder: sortRef.current.sortOrder, exclude, + type: getMarketplaceListFilterType(activePluginTypeRef.current), }) }, [queryPlugins, exclude]) diff --git a/web/app/components/plugins/marketplace/hooks.ts b/web/app/components/plugins/marketplace/hooks.ts index f7527fb0f6..f58bb9bacd 100644 --- a/web/app/components/plugins/marketplace/hooks.ts +++ b/web/app/components/plugins/marketplace/hooks.ts @@ -13,8 +13,8 @@ import type { PluginsSearchParams, } from './types' import { + getFormattedPlugin, getMarketplaceCollectionsAndPlugins, - getPluginIconInMarketplace, } from './utils' import i18n from '@/i18n/i18next-config' import { @@ -64,10 +64,9 @@ export const useMarketplacePlugins = () => { }) return { - plugins: data?.data?.plugins.map(plugin => ({ - ...plugin, - icon: getPluginIconInMarketplace(plugin), - })), + plugins: data?.data?.plugins.map((plugin) => { + return getFormattedPlugin(plugin) + }), resetPlugins: reset, queryPlugins, queryPluginsWithDebounced, diff --git a/web/app/components/plugins/marketplace/list/card-wrapper.tsx b/web/app/components/plugins/marketplace/list/card-wrapper.tsx index 9899fe657e..502a920212 100644 --- a/web/app/components/plugins/marketplace/list/card-wrapper.tsx +++ b/web/app/components/plugins/marketplace/list/card-wrapper.tsx @@ -1,9 +1,9 @@ 'use client' import { RiArrowRightUpLine } from '@remixicon/react' +import { getPluginLinkInMarketplace } from '../utils' import Card from '@/app/components/plugins/card' import CardMoreInfo from '@/app/components/plugins/card/card-more-info' import type { Plugin } from '@/app/components/plugins/types' -import { MARKETPLACE_URL_PREFIX } from '@/config' import Button from '@/app/components/base/button' import { useMixedTranslation } from '@/app/components/plugins/marketplace/hooks' import InstallFromMarketplace from '@/app/components/plugins/install-plugin/install-from-marketplace' @@ -55,7 +55,7 @@ const CardWrapper = ({ > {t('plugin.detailPanel.operation.install')} - +