mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 19:59:50 +08:00
30 lines
770 B
TypeScript
30 lines
770 B
TypeScript
import type { InstalledPluginListResponse } from '@/app/components/plugins/types'
|
|
import { get } from './base'
|
|
import {
|
|
useQueryClient,
|
|
} from '@tanstack/react-query'
|
|
|
|
import {
|
|
useQuery,
|
|
} from '@tanstack/react-query'
|
|
|
|
const NAME_SPACE = 'plugins'
|
|
|
|
const useInstalledPluginListKey = [NAME_SPACE, 'installedPluginList']
|
|
export const useInstalledPluginList = () => {
|
|
return useQuery<InstalledPluginListResponse>({
|
|
queryKey: useInstalledPluginListKey,
|
|
queryFn: () => get<InstalledPluginListResponse>('/workspaces/current/plugin/list'),
|
|
})
|
|
}
|
|
|
|
export const useInvalidateInstalledPluginList = () => {
|
|
const queryClient = useQueryClient()
|
|
return () => {
|
|
queryClient.invalidateQueries(
|
|
{
|
|
queryKey: useInstalledPluginListKey,
|
|
})
|
|
}
|
|
}
|