From bd205f63ccefa7c820ae5258a1a23c44b60379da Mon Sep 17 00:00:00 2001 From: StyleZhang Date: Mon, 4 Mar 2024 14:53:48 +0800 Subject: [PATCH] fix: workflow route --- web/app/(commonLayout)/apps/AppCard.tsx | 6 +++--- web/app/components/app/create-app-dialog/appForm.tsx | 7 ++++--- web/app/components/app/create-from-dsl-modal/index.tsx | 6 +++--- web/app/components/explore/app-list/index.tsx | 6 +++--- web/app/components/workflow/hooks.ts | 5 ++++- web/app/components/workflow/index.tsx | 2 -- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/web/app/(commonLayout)/apps/AppCard.tsx b/web/app/(commonLayout)/apps/AppCard.tsx index d9215914c7..f7d586cf74 100644 --- a/web/app/(commonLayout)/apps/AppCard.tsx +++ b/web/app/(commonLayout)/apps/AppCard.tsx @@ -122,12 +122,12 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => { }) localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') if (!isCurrentWorkspaceManager) { - push(`/app/${newApp.id}/'overview'`) + push(`/app/${newApp.id}/overview`) } else { if (newApp.mode === 'workflow' || newApp.mode === 'advanced-chat') - push(`/app/${newApp.id}/'workflow'`) - push(`/app/${newApp.id}/'configuration'`) + push(`/app/${newApp.id}/workflow`) + push(`/app/${newApp.id}/configuration`) } } catch (e) { diff --git a/web/app/components/app/create-app-dialog/appForm.tsx b/web/app/components/app/create-app-dialog/appForm.tsx index f82f29a40e..6310b67759 100644 --- a/web/app/components/app/create-app-dialog/appForm.tsx +++ b/web/app/components/app/create-app-dialog/appForm.tsx @@ -74,12 +74,13 @@ const AppForm = ({ onHide() mutateApps() if (!isCurrentWorkspaceManager) { - router.push(`/app/${app.id}/'overview'`) + router.push(`/app/${app.id}/overview`) } else { if (app.mode === 'workflow' || app.mode === 'advanced-chat') - router.push(`/app/${app.id}/'workflow'`) - router.push(`/app/${app.id}/'configuration'`) + router.push(`/app/${app.id}/workflow`) + else + router.push(`/app/${app.id}/configuration`) } } catch (e) { diff --git a/web/app/components/app/create-from-dsl-modal/index.tsx b/web/app/components/app/create-from-dsl-modal/index.tsx index 896a99ccac..344751ef30 100644 --- a/web/app/components/app/create-from-dsl-modal/index.tsx +++ b/web/app/components/app/create-from-dsl-modal/index.tsx @@ -68,12 +68,12 @@ const CreateFromDSLModal = ({ show, onSuccess, onClose }: CreateFromDSLModalProp notify({ type: 'success', message: t('app.newApp.appCreated') }) localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') if (!isCurrentWorkspaceManager) { - router.push(`/app/${app.id}/'overview'`) + router.push(`/app/${app.id}/overview`) } else { if (app.mode === 'workflow' || app.mode === 'advanced-chat') - router.push(`/app/${app.id}/'workflow'`) - router.push(`/app/${app.id}/'configuration'`) + router.push(`/app/${app.id}/workflow`) + router.push(`/app/${app.id}/configuration`) } } catch (e) { diff --git a/web/app/components/explore/app-list/index.tsx b/web/app/components/explore/app-list/index.tsx index d94d6aea55..77eeca775b 100644 --- a/web/app/components/explore/app-list/index.tsx +++ b/web/app/components/explore/app-list/index.tsx @@ -90,12 +90,12 @@ const Apps = ({ }) localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') if (!isCurrentWorkspaceManager) { - router.push(`/app/${app.id}/'overview'`) + router.push(`/app/${app.id}/overview`) } else { if (app.mode === 'workflow' || app.mode === 'advanced-chat') - router.push(`/app/${app.id}/'workflow'`) - router.push(`/app/${app.id}/'configuration'`) + router.push(`/app/${app.id}/workflow`) + router.push(`/app/${app.id}/configuration`) } } catch (e) { diff --git a/web/app/components/workflow/hooks.ts b/web/app/components/workflow/hooks.ts index 4686c9268f..0baf33867d 100644 --- a/web/app/components/workflow/hooks.ts +++ b/web/app/components/workflow/hooks.ts @@ -55,11 +55,14 @@ export const useWorkflow = () => { } = store.getState() e.stopPropagation() - const newNodes = produce(getNodes(), (draft) => { + const nodes = getNodes() + + const newNodes = produce(nodes, (draft) => { const currentNode = draft.find(n => n.id === node.id)! currentNode.position = node.position }) + setNodes(newNodes) }, [store]) diff --git a/web/app/components/workflow/index.tsx b/web/app/components/workflow/index.tsx index 3f4b817059..9da7a25c6a 100644 --- a/web/app/components/workflow/index.tsx +++ b/web/app/components/workflow/index.tsx @@ -47,8 +47,6 @@ const Workflow: FC = memo(({ const [edges, _, onEdgesChange] = useEdgesState(initialEdges) // const nodesInitialized = useNodesInitialized() - console.log(nodes) - const { // handleLayout,