feat: workflow preview

This commit is contained in:
Joel
2025-10-16 17:38:13 +08:00
parent 4bea38042a
commit 61ebc756aa
5 changed files with 50 additions and 5 deletions

View File

@ -8,6 +8,8 @@ import type {
import type { ModelConfig } from '@/types/app'
import qs from 'qs'
import type { DataSetListResponse } from '@/models/datasets'
import type { Edge, Node } from '@/app/components/workflow/types'
import type { Viewport } from 'reactflow'
type TryAppInfo = {
name: string
@ -25,3 +27,15 @@ export const fetchTryAppDatasets = (appId: string, ids: string[]) => {
const urlParams = qs.stringify({ ids }, { indices: false })
return get<DataSetListResponse>(`/trial-apps/${appId}/datasets?${urlParams}`)
}
type TryAppFlowPreview = {
graph: {
nodes: Node[]
edges: Edge[]
viewport: Viewport
}
}
export const fetchTryAppFlowPreview = (appId: string) => {
return get<TryAppFlowPreview>(`/trial-apps/${appId}/workflows`)
}

View File

@ -1,5 +1,5 @@
import { useQuery } from '@tanstack/react-query'
import { fetchTryAppDatasets, fetchTryAppInfo } from './try-app'
import { fetchTryAppDatasets, fetchTryAppFlowPreview, fetchTryAppInfo } from './try-app'
import { AppSourceType, fetchAppParams } from './share'
import type { DataSetListResponse } from '@/models/datasets'
@ -32,3 +32,12 @@ export const useGetTryAppDataSets = (appId: string, ids: string[]) => {
enabled: ids.length > 0,
})
}
export const useGetTryAppFlowPreview = (appId: string) => {
return useQuery({
queryKey: [NAME_SPACE, 'preview', appId],
queryFn: () => {
return fetchTryAppFlowPreview(appId)
},
})
}