mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-04 13:50:40 +08:00
chore: change init value
This commit is contained in:
parent
135f27b19b
commit
bc45c0904a
@ -1,8 +1,8 @@
|
|||||||
import type { NodeWithVar, VarInInspect } from '@/types/workflow'
|
import type { NodeWithVar, VarInInspect } from '@/types/workflow'
|
||||||
import { useWorkflowStore } from '../../workflow/store'
|
import { useWorkflowStore } from '../../workflow/store'
|
||||||
import { useWorkflowVars } from '@/service/use-workflow'
|
|
||||||
import { useStoreApi } from 'reactflow'
|
import { useStoreApi } from 'reactflow'
|
||||||
import type { Node } from '@/app/components/workflow/types'
|
import type { Node } from '@/app/components/workflow/types'
|
||||||
|
import { fetchAllInspectVars } from '@/service/workflow'
|
||||||
|
|
||||||
const useSetWorkflowVarsWithValue = () => {
|
const useSetWorkflowVarsWithValue = () => {
|
||||||
const workflowStore = useWorkflowStore()
|
const workflowStore = useWorkflowStore()
|
||||||
@ -46,7 +46,14 @@ const useSetWorkflowVarsWithValue = () => {
|
|||||||
})
|
})
|
||||||
setNodesWithInspectVars(res)
|
setNodesWithInspectVars(res)
|
||||||
}
|
}
|
||||||
useWorkflowVars(appId, addNodeInfo)
|
|
||||||
|
const fetchInspectVars = async () => {
|
||||||
|
const data = await fetchAllInspectVars(appId)
|
||||||
|
addNodeInfo(data)
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
fetchInspectVars,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default useSetWorkflowVarsWithValue
|
export default useSetWorkflowVarsWithValue
|
@ -82,7 +82,7 @@ import Confirm from '@/app/components/base/confirm'
|
|||||||
import DatasetsDetailProvider from './datasets-detail-store/provider'
|
import DatasetsDetailProvider from './datasets-detail-store/provider'
|
||||||
import { HooksStoreContextProvider } from './hooks-store'
|
import { HooksStoreContextProvider } from './hooks-store'
|
||||||
import type { Shape as HooksStoreShape } from './hooks-store'
|
import type { Shape as HooksStoreShape } from './hooks-store'
|
||||||
import useSetWorkflowVarsWithValue from '../workflow-app/hooks/use-set-workflow-vars-with-value'
|
import useSetWorkflowVarsWithValue from '../workflow-app/hooks/use-fetch-workflow-inspect-vars'
|
||||||
|
|
||||||
const nodeTypes = {
|
const nodeTypes = {
|
||||||
[CUSTOM_NODE]: CustomNode,
|
[CUSTOM_NODE]: CustomNode,
|
||||||
@ -274,7 +274,11 @@ export const Workflow: FC<WorkflowProps> = memo(({
|
|||||||
})
|
})
|
||||||
|
|
||||||
useShortcuts()
|
useShortcuts()
|
||||||
useSetWorkflowVarsWithValue()
|
const { fetchInspectVars } = useSetWorkflowVarsWithValue()
|
||||||
|
useEffect(() => {
|
||||||
|
fetchInspectVars()
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [])
|
||||||
|
|
||||||
const store = useStoreApi()
|
const store = useStoreApi()
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
|
@ -7,13 +7,11 @@ import type {
|
|||||||
NodeTracing,
|
NodeTracing,
|
||||||
PublishWorkflowParams,
|
PublishWorkflowParams,
|
||||||
UpdateWorkflowParams,
|
UpdateWorkflowParams,
|
||||||
VarInInspect,
|
|
||||||
WorkflowConfigResponse,
|
WorkflowConfigResponse,
|
||||||
} from '@/types/workflow'
|
} from '@/types/workflow'
|
||||||
import type { CommonResponse } from '@/models/common'
|
import type { CommonResponse } from '@/models/common'
|
||||||
import { useReset } from './use-base'
|
import { useReset } from './use-base'
|
||||||
import { sleep } from '@/utils'
|
import { sleep } from '@/utils'
|
||||||
import { vars } from '@/app/components/workflow/store/workflow/debug/mock-data'
|
|
||||||
|
|
||||||
const NAME_SPACE = 'workflow'
|
const NAME_SPACE = 'workflow'
|
||||||
|
|
||||||
@ -125,20 +123,3 @@ export const useLastRun = (appID: string, nodeId: string, enabled: boolean) => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useWorkflowVars = (appId: string, onSuccess: (data: VarInInspect[]) => void) => {
|
|
||||||
return useQuery({
|
|
||||||
queryKey: [NAME_SPACE, 'variables', appId],
|
|
||||||
queryFn: async () => {
|
|
||||||
// TODO: mock data. and need to get the rest data if has more data
|
|
||||||
await sleep(1000)
|
|
||||||
const data = await Promise.resolve({
|
|
||||||
items: vars,
|
|
||||||
total: 1,
|
|
||||||
})
|
|
||||||
onSuccess(data.items)
|
|
||||||
|
|
||||||
return data
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
@ -9,6 +9,9 @@ import type {
|
|||||||
WorkflowRunHistoryResponse,
|
WorkflowRunHistoryResponse,
|
||||||
} from '@/types/workflow'
|
} from '@/types/workflow'
|
||||||
import type { BlockEnum } from '@/app/components/workflow/types'
|
import type { BlockEnum } from '@/app/components/workflow/types'
|
||||||
|
import { sleep } from '@/utils'
|
||||||
|
import { vars } from '@/app/components/workflow/store/workflow/debug/mock-data'
|
||||||
|
import type { VarInInspect } from '@/types/workflow'
|
||||||
|
|
||||||
export const fetchWorkflowDraft = (url: string) => {
|
export const fetchWorkflowDraft = (url: string) => {
|
||||||
return get(url, {}, { silent: true }) as Promise<FetchWorkflowDraftResponse>
|
return get(url, {}, { silent: true }) as Promise<FetchWorkflowDraftResponse>
|
||||||
@ -70,3 +73,15 @@ export const fetchCurrentValueOfConversationVariable: Fetcher<ConversationVariab
|
|||||||
}> = ({ url, params }) => {
|
}> = ({ url, params }) => {
|
||||||
return get<ConversationVariableResponse>(url, { params })
|
return get<ConversationVariableResponse>(url, { params })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const fetchAllInspectVars = async (appId: string): Promise<VarInInspect[]> => {
|
||||||
|
// TODO: mock data. and need to get the rest data if has more data
|
||||||
|
await sleep(1000)
|
||||||
|
const data = await Promise.resolve({
|
||||||
|
items: vars,
|
||||||
|
total: 1,
|
||||||
|
})
|
||||||
|
const res = data.items
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
@ -395,5 +395,5 @@ export type NodeWithVar = {
|
|||||||
title: string
|
title: string
|
||||||
vars: VarInInspect[]
|
vars: VarInInspect[]
|
||||||
isFetchingValues?: boolean
|
isFetchingValues?: boolean
|
||||||
isSingRunRunning: boolean
|
isSingRunRunning?: boolean
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user