2024-11-08 15:10:06 +08:00
|
|
|
import type { DebugInfo as DebugInfoTypes, InstalledPluginListResponse } from '@/app/components/plugins/types'
|
2024-11-07 16:52:22 +08:00
|
|
|
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,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2024-11-08 15:10:06 +08:00
|
|
|
|
|
|
|
export const useDebugKey = () => {
|
|
|
|
return useQuery({
|
|
|
|
queryKey: [NAME_SPACE, 'debugKey'],
|
|
|
|
queryFn: () => get<DebugInfoTypes>('/workspaces/current/plugin/debugging-key'),
|
|
|
|
})
|
|
|
|
}
|