mirror of
https://github.com/langgenius/dify.git
synced 2026-05-04 01:18:05 +08:00
feat: fetch plugin list
This commit is contained in:
@ -1,11 +1,13 @@
|
||||
'use client'
|
||||
import type { FC } from 'react'
|
||||
import React, { useCallback } from 'react'
|
||||
import React, { useCallback, useState } from 'react'
|
||||
import {
|
||||
PortalToFollowElem,
|
||||
PortalToFollowElemContent,
|
||||
PortalToFollowElemTrigger,
|
||||
} from '@/app/components/base/portal-to-follow-elem'
|
||||
import { useFetchPluginListOrBundleList } from '@/service/use-plugins'
|
||||
import { PLUGIN_TYPE_SEARCH_MAP } from '../../marketplace/plugin-type-switch'
|
||||
|
||||
type Props = {
|
||||
trigger: React.ReactNode
|
||||
@ -16,6 +18,8 @@ type Props = {
|
||||
|
||||
}
|
||||
|
||||
const allPluginTypes = [PLUGIN_TYPE_SEARCH_MAP.all, PLUGIN_TYPE_SEARCH_MAP.model, PLUGIN_TYPE_SEARCH_MAP.tool, PLUGIN_TYPE_SEARCH_MAP.agent, PLUGIN_TYPE_SEARCH_MAP.extension, PLUGIN_TYPE_SEARCH_MAP.bundle]
|
||||
|
||||
const ToolPicker: FC<Props> = ({
|
||||
trigger,
|
||||
value,
|
||||
@ -26,6 +30,16 @@ const ToolPicker: FC<Props> = ({
|
||||
const toggleShowPopup = useCallback(() => {
|
||||
onShowChange(!isShow)
|
||||
}, [onShowChange, isShow])
|
||||
|
||||
const [pluginType, setPluginType] = useState(PLUGIN_TYPE_SEARCH_MAP.all)
|
||||
const [query, setQuery] = useState('')
|
||||
const { data } = useFetchPluginListOrBundleList({
|
||||
query,
|
||||
category: pluginType,
|
||||
})
|
||||
const isBundle = pluginType === PLUGIN_TYPE_SEARCH_MAP.bundle
|
||||
const list = (isBundle ? data?.data?.bundles : data?.data?.plugins) || []
|
||||
console.log(list)
|
||||
return (
|
||||
<PortalToFollowElem
|
||||
placement='top-start'
|
||||
|
||||
Reference in New Issue
Block a user