Feat/plugins (#12547)

Co-authored-by: AkaraChen <akarachen@outlook.com>
Co-authored-by: Yi <yxiaoisme@gmail.com>
Co-authored-by: Joel <iamjoel007@gmail.com>
Co-authored-by: JzoNg <jzongcode@gmail.com>
Co-authored-by: twwu <twwu@dify.ai>
Co-authored-by: kurokobo <kuro664@gmail.com>
Co-authored-by: Hiroshi Fujita <fujita-h@users.noreply.github.com>
This commit is contained in:
zxhlyh
2025-01-09 18:47:41 +08:00
committed by GitHub
parent e4c4490175
commit 3c014f3ae5
719 changed files with 48585 additions and 8553 deletions

View File

@ -0,0 +1,17 @@
import { useCallback } from 'react'
import { useStore as usePluginDependenciesStore } from './store'
import { useMutationCheckDependencies } from '@/service/use-plugins'
export const usePluginDependencies = () => {
const { mutateAsync } = useMutationCheckDependencies()
const handleCheckPluginDependencies = useCallback(async (appId: string) => {
const { leaked_dependencies } = await mutateAsync(appId)
const { setDependencies } = usePluginDependenciesStore.getState()
setDependencies(leaked_dependencies)
}, [mutateAsync])
return {
handleCheckPluginDependencies,
}
}

View File

@ -0,0 +1,24 @@
import { useCallback } from 'react'
import { useStore } from './store'
import InstallBundle from '@/app/components/plugins/install-plugin/install-bundle'
const PluginDependency = () => {
const dependencies = useStore(s => s.dependencies)
const handleCancelInstallBundle = useCallback(() => {
const { setDependencies } = useStore.getState()
setDependencies([])
}, [])
if (!dependencies.length)
return null
return (
<InstallBundle
fromDSLPayload={dependencies}
onClose={handleCancelInstallBundle}
/>
)
}
export default PluginDependency

View File

@ -0,0 +1,11 @@
import { create } from 'zustand'
import type { Dependency } from '@/app/components/plugins/types'
type Shape = {
dependencies: Dependency[]
setDependencies: (dependencies: Dependency[]) => void
}
export const useStore = create<Shape>(set => ({
dependencies: [],
setDependencies: dependencies => set({ dependencies }),
}))