mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-05 19:06:07 +08:00
chore: enchance set inspect var value and remove node vars
This commit is contained in:
parent
50440cdcf0
commit
8413090c49
@ -59,30 +59,31 @@ export const createInspectVarsSlice: StateCreator<InspectVarsSliceShape> = (set,
|
||||
})
|
||||
},
|
||||
deleteNodeInspectVars: (nodeId) => {
|
||||
set(produce((state: InspectVarsSliceShape) => {
|
||||
set((state: InspectVarsSliceShape) => {
|
||||
const nodes = state.nodesWithInspectVars.filter(node => node.nodeId !== nodeId)
|
||||
state.nodesWithInspectVars = nodes
|
||||
return {
|
||||
nodesWithInspectVars: nodes,
|
||||
}
|
||||
},
|
||||
))
|
||||
)
|
||||
},
|
||||
setInspectVarValue: (nodeId, varId, value) => {
|
||||
set(produce((state: InspectVarsSliceShape) => {
|
||||
const nodes = state.nodesWithInspectVars.map((node) => {
|
||||
if (node.nodeId === nodeId) {
|
||||
return produce(node, (draft) => {
|
||||
const needChangeVarIndex = draft.vars.findIndex((varItem) => {
|
||||
return varItem.id === varId
|
||||
})
|
||||
if (needChangeVarIndex !== -1) {
|
||||
draft.vars[needChangeVarIndex].value = value
|
||||
draft.vars[needChangeVarIndex].edited = true
|
||||
}
|
||||
})
|
||||
}
|
||||
return node
|
||||
})
|
||||
state.nodesWithInspectVars = nodes
|
||||
}))
|
||||
set((state: InspectVarsSliceShape) => {
|
||||
const nodes = produce(state.nodesWithInspectVars, (draft) => {
|
||||
const targetNode = draft.find(node => node.nodeId === nodeId)
|
||||
if (!targetNode)
|
||||
return
|
||||
const targetVar = targetNode.vars.find(varItem => varItem.id === varId)
|
||||
if(!targetVar)
|
||||
return
|
||||
targetVar.value = value
|
||||
targetVar.edited = true
|
||||
},
|
||||
)
|
||||
return {
|
||||
nodesWithInspectVars: nodes,
|
||||
}
|
||||
})
|
||||
},
|
||||
renameInspectVarName: (nodeId, varId, selector) => {
|
||||
set((state: InspectVarsSliceShape) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user