mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 10:28:10 +08:00
fix
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
import { useCallback } from 'react'
|
import { useCallback } from 'react'
|
||||||
import produce from 'immer'
|
import produce from 'immer'
|
||||||
import { useStoreApi } from 'reactflow'
|
import { useStoreApi } from 'reactflow'
|
||||||
|
import { useParams } from 'next/navigation'
|
||||||
import {
|
import {
|
||||||
useStore,
|
useStore,
|
||||||
useWorkflowStore,
|
useWorkflowStore,
|
||||||
@ -17,6 +18,7 @@ export const useNodesSyncDraft = () => {
|
|||||||
const featuresStore = useFeaturesStore()
|
const featuresStore = useFeaturesStore()
|
||||||
const { getNodesReadOnly } = useNodesReadOnly()
|
const { getNodesReadOnly } = useNodesReadOnly()
|
||||||
const debouncedSyncWorkflowDraft = useStore(s => s.debouncedSyncWorkflowDraft)
|
const debouncedSyncWorkflowDraft = useStore(s => s.debouncedSyncWorkflowDraft)
|
||||||
|
const params = useParams()
|
||||||
|
|
||||||
const doSyncWorkflowDraft = useCallback(async () => {
|
const doSyncWorkflowDraft = useCallback(async () => {
|
||||||
const {
|
const {
|
||||||
@ -27,7 +29,7 @@ export const useNodesSyncDraft = () => {
|
|||||||
const [x, y, zoom] = transform
|
const [x, y, zoom] = transform
|
||||||
const appId = useAppStore.getState().appDetail?.id
|
const appId = useAppStore.getState().appDetail?.id
|
||||||
|
|
||||||
if (appId) {
|
if (appId || params.appId) {
|
||||||
const nodes = getNodes()
|
const nodes = getNodes()
|
||||||
const hasStartNode = nodes.find(node => node.data.type === BlockEnum.Start)
|
const hasStartNode = nodes.find(node => node.data.type === BlockEnum.Start)
|
||||||
|
|
||||||
@ -52,7 +54,7 @@ export const useNodesSyncDraft = () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
syncWorkflowDraft({
|
syncWorkflowDraft({
|
||||||
url: `/apps/${appId}/workflows/draft`,
|
url: `/apps/${appId || params.appId}/workflows/draft`,
|
||||||
params: {
|
params: {
|
||||||
graph: {
|
graph: {
|
||||||
nodes: producedNodes,
|
nodes: producedNodes,
|
||||||
@ -78,7 +80,7 @@ export const useNodesSyncDraft = () => {
|
|||||||
workflowStore.getState().setDraftUpdatedAt(res.updated_at)
|
workflowStore.getState().setDraftUpdatedAt(res.updated_at)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, [store, featuresStore, workflowStore])
|
}, [store, featuresStore, workflowStore, params.appId])
|
||||||
|
|
||||||
const handleSyncWorkflowDraft = useCallback((sync?: boolean) => {
|
const handleSyncWorkflowDraft = useCallback((sync?: boolean) => {
|
||||||
if (getNodesReadOnly())
|
if (getNodesReadOnly())
|
||||||
|
|||||||
Reference in New Issue
Block a user