From f70b3b2a32eb662a8f4e9d7e7b433055c29bab1b Mon Sep 17 00:00:00 2001 From: v-zhangjc9 Date: Thu, 10 Jul 2025 14:28:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(web):=20=E7=A7=BB=E9=99=A4=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=9C=AA=E7=A7=BB=E9=99=A4=E8=8A=82=E7=82=B9=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service-web/client/src/components/flow/node/AmisNode.tsx | 9 ++++++--- service-web/client/src/components/flow/node/LlmNode.tsx | 5 ++--- .../client/src/components/flow/store/DataStore.ts | 8 ++++++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/service-web/client/src/components/flow/node/AmisNode.tsx b/service-web/client/src/components/flow/node/AmisNode.tsx index e5d7b0d..c73542e 100644 --- a/service-web/client/src/components/flow/node/AmisNode.tsx +++ b/service-web/client/src/components/flow/node/AmisNode.tsx @@ -47,7 +47,6 @@ export function inputsFormColumns( })) let incomerIds = getAllIncomerNodeById(nodeId, nodes, edges) - console.log(incomerIds, nodes, edges) let incomerVariables: InputFormOptionsGroup[] = [] for (const incomerId of incomerIds) { let nodeData = data[incomerId] ?? {} @@ -195,7 +194,7 @@ const AmisNode: (props: AmisNodeProps) => JSX.Element = ({ columnSchema, }) => { const {removeNode} = useFlowStore() - const {getDataById, setDataById} = useDataStore() + const {getDataById, setDataById, removeDataById} = useDataStore() const {id} = nodeProps // @ts-ignore const nodeData = getDataById(id) @@ -291,6 +290,10 @@ const AmisNode: (props: AmisNodeProps) => JSX.Element = ({ ) setEditDrawerOpen(true) }, [nodeData]) + const remove = useCallback(() => { + removeNode(id) + removeDataById(id) + }, []) return ( JSX.Element = ({ size="small" icon={} block - onClick={() => removeNode(id)} + onClick={() => remove()} />, ]} > diff --git a/service-web/client/src/components/flow/node/LlmNode.tsx b/service-web/client/src/components/flow/node/LlmNode.tsx index 57beb38..6a21b1a 100644 --- a/service-web/client/src/components/flow/node/LlmNode.tsx +++ b/service-web/client/src/components/flow/node/LlmNode.tsx @@ -1,6 +1,6 @@ import type {NodeProps} from '@xyflow/react' import {Tag} from 'antd' -import React, {useCallback, useEffect, useState} from 'react' +import React, {useCallback, useEffect} from 'react' import {useContextStore} from '../store/ContextStore.ts' import {useDataStore} from '../store/DataStore.ts' import {useFlowStore} from '../store/FlowStore.ts' @@ -16,7 +16,7 @@ const LlmNode = (props: NodeProps) => { const {getData, mergeDataById, getDataById} = useDataStore() const {getInputSchema} = useContextStore() - const [nodeData, setNodeData] = useState() + const nodeData = getDataById(props.id) useEffect(() => { mergeDataById( @@ -29,7 +29,6 @@ const LlmNode = (props: NodeProps) => { }, }, ) - setNodeData(getDataById(props.id)) }, [props.id]) const columnsSchema = useCallback(() => [ diff --git a/service-web/client/src/components/flow/store/DataStore.ts b/service-web/client/src/components/flow/store/DataStore.ts index 3fc26fc..fbe4b28 100644 --- a/service-web/client/src/components/flow/store/DataStore.ts +++ b/service-web/client/src/components/flow/store/DataStore.ts @@ -7,6 +7,7 @@ export type DataStoreState = { getDataById: (id: string) => any, setDataById: (id: string, data: any) => void, mergeDataById: (id: string, data: any) => void, + removeDataById: (id: string) => void, } export const useDataStore = create((set, get) => ({ @@ -33,4 +34,11 @@ export const useDataStore = create((set, get) => ({ data: updateData, }) }, + removeDataById: (id) => { + let data = get().data + delete data[id] + set({ + data, + }) + }, })) \ No newline at end of file