This commit is contained in:
StyleZhang 2024-04-03 14:37:51 +08:00
parent 3f11e11c2d
commit 28e813f57f
1 changed files with 10 additions and 3 deletions

View File

@ -5,11 +5,14 @@ import {
memo,
useCallback,
useEffect,
useLayoutEffect,
useMemo,
} from 'react'
import { useParams } from 'next/navigation'
import { setAutoFreeze } from 'immer'
import { useKeyPress } from 'ahooks'
import {
useKeyPress,
} from 'ahooks'
import ReactFlow, {
Background,
ReactFlowProvider,
@ -48,6 +51,7 @@ import {
import Loading from '@/app/components/base/loading'
import { FeaturesProvider } from '@/app/components/base/features'
import type { Features as FeaturesData } from '@/app/components/base/features/types'
import { useStore as useAppStore } from '@/app/components/app/store'
const nodeTypes = {
custom: CustomNode,
@ -84,10 +88,13 @@ const Workflow: FC<WorkflowProps> = memo(({
}
}, [])
useEffect(() => {
useLayoutEffect(() => {
const appId = params.appId
return () => {
handleSyncWorkflowDraft(true, appId as string)
const appIdParams = useAppStore.getState().appDetail?.id
if (appId !== appIdParams)
handleSyncWorkflowDraft(true, appId as string)
}
}, [])