mirror of https://github.com/langgenius/dify.git
feat: handleupdate logic
This commit is contained in:
parent
474c7865d7
commit
a36a2a1080
|
|
@ -0,0 +1,19 @@
|
|||
import { useWorkflow } from '@/app/components/workflow/hooks'
|
||||
import type { CommonNodeType } from '@/app/components/workflow/types'
|
||||
const useNodeCrud = <T>(id: string, data: CommonNodeType<T>) => {
|
||||
const { handleNodeDataUpdate } = useWorkflow()
|
||||
|
||||
const setInputs = (newInputs: CommonNodeType<T>) => {
|
||||
handleNodeDataUpdate({
|
||||
id,
|
||||
data: newInputs,
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
inputs: data,
|
||||
setInputs,
|
||||
}
|
||||
}
|
||||
|
||||
export default useNodeCrud
|
||||
|
|
@ -3,17 +3,10 @@ import produce from 'immer'
|
|||
import { useBoolean } from 'ahooks'
|
||||
import type { StartNodeType } from './types'
|
||||
import type { InputVar } from '@/app/components/workflow/types'
|
||||
import { useWorkflow } from '@/app/components/workflow/hooks'
|
||||
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
|
||||
|
||||
const useConfig = (id: string, payload: StartNodeType) => {
|
||||
const { handleNodeDataUpdate } = useWorkflow()
|
||||
// const [inputs, setInputs] = useState<StartNodeType>(initInputs)
|
||||
const inputs = payload
|
||||
const setInputs = (newInputs: StartNodeType) => {
|
||||
handleNodeDataUpdate({
|
||||
id,
|
||||
data: newInputs,
|
||||
})
|
||||
}
|
||||
const { inputs, setInputs } = useNodeCrud<StartNodeType>(id, payload)
|
||||
|
||||
const [isShowAddVarModal, {
|
||||
setTrue: showAddVarModal,
|
||||
|
|
|
|||
Loading…
Reference in New Issue