fix(web): 移除节点未移除节点数据

This commit is contained in:
v-zhangjc9
2025-07-10 14:28:32 +08:00
parent f707a0d2b5
commit f70b3b2a32
3 changed files with 16 additions and 6 deletions

View File

@@ -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 (
<AmisNodeContainerDiv className="w-64">
<Drawer
@@ -331,7 +334,7 @@ const AmisNode: (props: AmisNodeProps) => JSX.Element = ({
size="small"
icon={<DeleteFilled/>}
block
onClick={() => removeNode(id)}
onClick={() => remove()}
/>,
]}
>

View File

@@ -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<any>()
const nodeData = getDataById(props.id)
useEffect(() => {
mergeDataById(
@@ -29,7 +29,6 @@ const LlmNode = (props: NodeProps) => {
},
},
)
setNodeData(getDataById(props.id))
}, [props.id])
const columnsSchema = useCallback(() => [

View File

@@ -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<DataStoreState>((set, get) => ({
@@ -33,4 +34,11 @@ export const useDataStore = create<DataStoreState>((set, get) => ({
data: updateData,
})
},
removeDataById: (id) => {
let data = get().data
delete data[id]
set({
data,
})
},
}))