feat: loop start add index (#3101)

* feat: loop start add index

* update doc
This commit is contained in:
Archer
2024-11-08 17:21:19 +08:00
committed by archer
parent 6c6c964b8a
commit 49aaf9b77e
7 changed files with 66 additions and 45 deletions

View File

@@ -43,6 +43,7 @@ export const dispatchLoop = async (props: Props): Promise<Response> => {
let totalPoints = 0;
let newVariables: Record<string, any> = props.variables;
let index = 0;
for await (const item of loopInputArray.filter(Boolean)) {
runtimeNodes.forEach((node) => {
if (
@@ -50,14 +51,21 @@ export const dispatchLoop = async (props: Props): Promise<Response> => {
node.flowNodeType === FlowNodeTypeEnum.loopStart
) {
node.isEntry = true;
node.inputs = node.inputs.map((input) =>
input.key === NodeInputKeyEnum.loopStartInput
? {
...input,
value: item
}
: input
);
node.inputs = node.inputs.map((input) => {
if (input.key === NodeInputKeyEnum.loopStartInput) {
return {
...input,
value: item
};
} else if (input.key === NodeInputKeyEnum.loopStartInput) {
return {
...input,
value: index++
};
} else {
return input;
}
});
}
});
const response = await dispatchWorkFlow({