mirror of
https://github.com/langgenius/dify.git
synced 2026-01-28 22:53:23 +08:00
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { useQuery } from '@tanstack/react-query'
|
|
import { fetchTryAppDatasets, fetchTryAppFlowPreview, fetchTryAppInfo } from './try-app'
|
|
import { AppSourceType, fetchAppParams } from './share'
|
|
import type { DataSetListResponse } from '@/models/datasets'
|
|
|
|
const NAME_SPACE = 'try-app'
|
|
|
|
export const useGetTryAppInfo = (appId: string) => {
|
|
return useQuery({
|
|
queryKey: [NAME_SPACE, 'appInfo', appId],
|
|
queryFn: () => {
|
|
return fetchTryAppInfo(appId)
|
|
},
|
|
})
|
|
}
|
|
|
|
export const useGetTryAppParams = (appId: string) => {
|
|
return useQuery({
|
|
queryKey: [NAME_SPACE, 'appParams', appId],
|
|
queryFn: () => {
|
|
return fetchAppParams(AppSourceType.tryApp, appId)
|
|
},
|
|
})
|
|
}
|
|
|
|
export const useGetTryAppDataSets = (appId: string, ids: string[]) => {
|
|
return useQuery<DataSetListResponse>({
|
|
queryKey: [NAME_SPACE, 'dataSets', appId, ids],
|
|
queryFn: () => {
|
|
return fetchTryAppDatasets(appId, ids)
|
|
},
|
|
enabled: ids.length > 0,
|
|
})
|
|
}
|
|
|
|
export const useGetTryAppFlowPreview = (appId: string) => {
|
|
return useQuery({
|
|
queryKey: [NAME_SPACE, 'preview', appId],
|
|
queryFn: () => {
|
|
return fetchTryAppFlowPreview(appId)
|
|
},
|
|
})
|
|
}
|