fix(web): 移除节点未移除节点数据
This commit is contained in:
@@ -47,7 +47,6 @@ export function inputsFormColumns(
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
let incomerIds = getAllIncomerNodeById(nodeId, nodes, edges)
|
let incomerIds = getAllIncomerNodeById(nodeId, nodes, edges)
|
||||||
console.log(incomerIds, nodes, edges)
|
|
||||||
let incomerVariables: InputFormOptionsGroup[] = []
|
let incomerVariables: InputFormOptionsGroup[] = []
|
||||||
for (const incomerId of incomerIds) {
|
for (const incomerId of incomerIds) {
|
||||||
let nodeData = data[incomerId] ?? {}
|
let nodeData = data[incomerId] ?? {}
|
||||||
@@ -195,7 +194,7 @@ const AmisNode: (props: AmisNodeProps) => JSX.Element = ({
|
|||||||
columnSchema,
|
columnSchema,
|
||||||
}) => {
|
}) => {
|
||||||
const {removeNode} = useFlowStore()
|
const {removeNode} = useFlowStore()
|
||||||
const {getDataById, setDataById} = useDataStore()
|
const {getDataById, setDataById, removeDataById} = useDataStore()
|
||||||
const {id} = nodeProps
|
const {id} = nodeProps
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const nodeData = getDataById(id)
|
const nodeData = getDataById(id)
|
||||||
@@ -291,6 +290,10 @@ const AmisNode: (props: AmisNodeProps) => JSX.Element = ({
|
|||||||
)
|
)
|
||||||
setEditDrawerOpen(true)
|
setEditDrawerOpen(true)
|
||||||
}, [nodeData])
|
}, [nodeData])
|
||||||
|
const remove = useCallback(() => {
|
||||||
|
removeNode(id)
|
||||||
|
removeDataById(id)
|
||||||
|
}, [])
|
||||||
return (
|
return (
|
||||||
<AmisNodeContainerDiv className="w-64">
|
<AmisNodeContainerDiv className="w-64">
|
||||||
<Drawer
|
<Drawer
|
||||||
@@ -331,7 +334,7 @@ const AmisNode: (props: AmisNodeProps) => JSX.Element = ({
|
|||||||
size="small"
|
size="small"
|
||||||
icon={<DeleteFilled/>}
|
icon={<DeleteFilled/>}
|
||||||
block
|
block
|
||||||
onClick={() => removeNode(id)}
|
onClick={() => remove()}
|
||||||
/>,
|
/>,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type {NodeProps} from '@xyflow/react'
|
import type {NodeProps} from '@xyflow/react'
|
||||||
import {Tag} from 'antd'
|
import {Tag} from 'antd'
|
||||||
import React, {useCallback, useEffect, useState} from 'react'
|
import React, {useCallback, useEffect} from 'react'
|
||||||
import {useContextStore} from '../store/ContextStore.ts'
|
import {useContextStore} from '../store/ContextStore.ts'
|
||||||
import {useDataStore} from '../store/DataStore.ts'
|
import {useDataStore} from '../store/DataStore.ts'
|
||||||
import {useFlowStore} from '../store/FlowStore.ts'
|
import {useFlowStore} from '../store/FlowStore.ts'
|
||||||
@@ -16,7 +16,7 @@ const LlmNode = (props: NodeProps) => {
|
|||||||
const {getData, mergeDataById, getDataById} = useDataStore()
|
const {getData, mergeDataById, getDataById} = useDataStore()
|
||||||
const {getInputSchema} = useContextStore()
|
const {getInputSchema} = useContextStore()
|
||||||
|
|
||||||
const [nodeData, setNodeData] = useState<any>()
|
const nodeData = getDataById(props.id)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
mergeDataById(
|
mergeDataById(
|
||||||
@@ -29,7 +29,6 @@ const LlmNode = (props: NodeProps) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
setNodeData(getDataById(props.id))
|
|
||||||
}, [props.id])
|
}, [props.id])
|
||||||
|
|
||||||
const columnsSchema = useCallback(() => [
|
const columnsSchema = useCallback(() => [
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export type DataStoreState = {
|
|||||||
getDataById: (id: string) => any,
|
getDataById: (id: string) => any,
|
||||||
setDataById: (id: string, data: any) => void,
|
setDataById: (id: string, data: any) => void,
|
||||||
mergeDataById: (id: string, data: any) => void,
|
mergeDataById: (id: string, data: any) => void,
|
||||||
|
removeDataById: (id: string) => void,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useDataStore = create<DataStoreState>((set, get) => ({
|
export const useDataStore = create<DataStoreState>((set, get) => ({
|
||||||
@@ -33,4 +34,11 @@ export const useDataStore = create<DataStoreState>((set, get) => ({
|
|||||||
data: updateData,
|
data: updateData,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
removeDataById: (id) => {
|
||||||
|
let data = get().data
|
||||||
|
delete data[id]
|
||||||
|
set({
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
},
|
||||||
}))
|
}))
|
||||||
Reference in New Issue
Block a user