dify/web/app/components/plugins/marketplace/index.tsx

38 lines
1.6 KiB
TypeScript
Raw Normal View History

2024-10-28 11:50:26 +08:00
import type { Plugin } from '../types'
2024-10-12 18:02:24 +08:00
import { MarketplaceContextProvider } from './context'
import Description from './description'
import IntersectionLine from './intersection-line'
import SearchBox from './search-box'
import PluginTypeSwitch from './plugin-type-switch'
2024-10-28 11:50:26 +08:00
import ListWrapper from './list/list-wrapper'
import type { MarketplaceCollection } from './types'
const Marketplace = async () => {
const marketplaceCollectionsData = await globalThis.fetch('https://marketplace.dify.dev/api/v1/collections')
const marketplaceCollectionsDataJson = await marketplaceCollectionsData.json()
const marketplaceCollections = marketplaceCollectionsDataJson.data.collections
const marketplaceCollectionPluginsMap = {} as Record<string, Plugin[]>
await Promise.all(marketplaceCollections.map(async (collection: MarketplaceCollection) => {
const marketplaceCollectionPluginsData = await globalThis.fetch(`https://marketplace.dify.dev/api/v1/collections/${collection.name}/plugins`)
const marketplaceCollectionPluginsDataJson = await marketplaceCollectionPluginsData.json()
const plugins = marketplaceCollectionPluginsDataJson.data.plugins
marketplaceCollectionPluginsMap[collection.name] = plugins
}))
2024-10-08 17:57:46 +08:00
return (
2024-10-12 18:02:24 +08:00
<MarketplaceContextProvider>
<Description />
<IntersectionLine />
<SearchBox />
<PluginTypeSwitch />
2024-10-28 11:50:26 +08:00
<ListWrapper
marketplaceCollections={marketplaceCollections}
marketplaceCollectionPluginsMap={marketplaceCollectionPluginsMap}
/>
2024-10-12 18:02:24 +08:00
</MarketplaceContextProvider>
2024-10-08 17:57:46 +08:00
)
}
2024-10-11 16:15:24 +08:00
export default Marketplace