refactor(web): migrate workflow run history from useSWR to TanStack Query (#30077)

This commit is contained in:
yyh
2025-12-24 18:21:01 +08:00
committed by GitHub
parent 64a14dcdbc
commit 5896bc89f5
6 changed files with 19 additions and 45 deletions

View File

@ -9,6 +9,7 @@ import type {
UpdateWorkflowParams,
VarInInspect,
WorkflowConfigResponse,
WorkflowRunHistoryResponse,
} from '@/types/workflow'
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { del, get, patch, post, put } from './base'
@ -25,6 +26,14 @@ export const useAppWorkflow = (appID: string) => {
})
}
export const useWorkflowRunHistory = (url?: string, enabled = true) => {
return useQuery<WorkflowRunHistoryResponse>({
queryKey: [NAME_SPACE, 'runHistory', url],
queryFn: () => get<WorkflowRunHistoryResponse>(url as string),
enabled: !!url && enabled,
})
}
export const useInvalidateAppWorkflow = () => {
const queryClient = useQueryClient()
return (appID: string) => {