mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 01:48:04 +08:00
feat: workflow preview
This commit is contained in:
@ -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`)
|
||||
}
|
||||
|
||||
@ -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)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user