From 21a400e1725a9904afea0eb0da3a98bff48e9b71 Mon Sep 17 00:00:00 2001 From: yu <1919727607@qq.com> Date: Thu, 5 Nov 2026 12:47:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=90=E8=A1=8C=E5=89=8D=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E8=AF=86=E5=88=AB=E5=BE=AA=E7=8E=AF=E5=AE=B9=E5=99=A8=E6=B3=A8?= =?UTF-8?q?=E5=85=A5=E7=9A=84=E8=BF=AD=E4=BB=A3=E5=8F=98=E9=87=8F\n\n-=20?= =?UTF-8?q?=E6=95=B0=E7=BB=84/=E5=AD=97=E5=85=B8=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=97=B6=E6=B3=A8=E5=85=A5=20item/index/valu?= =?UTF-8?q?e,=20=E8=AE=A1=E6=95=B0=E5=BE=AA=E7=8E=AF=E6=B3=A8=E5=85=A5?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E7=B4=A2=E5=BC=95=E5=8F=98=E9=87=8F?= =?UTF-8?q?\n-=20=E6=A0=A1=E9=AA=8C=E5=99=A8=E5=8E=9F=E5=85=88=E5=8F=AA?= =?UTF-8?q?=E8=AE=A4=20flow.variables=20=E4=B8=8E=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E5=8F=98=E9=87=8F,=20=E5=AF=B9=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E4=BD=93=E5=86=85=E5=BC=95=E7=94=A8=E8=AF=AF=E6=8A=A5?= =?UTF-8?q?=E6=9C=AA=E5=AE=9A=E4=B9=89=E5=8F=98=E9=87=8F=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/validation/flowValidation.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/renderer/src/validation/flowValidation.ts b/src/renderer/src/validation/flowValidation.ts index d2b89af..443b909 100644 --- a/src/renderer/src/validation/flowValidation.ts +++ b/src/renderer/src/validation/flowValidation.ts @@ -122,6 +122,20 @@ export function validateFlow(flow: FlowDefinition, catalog: Catalog): FlowValida ...(flow.variables ?? []).map((item) => item.name), ...flow.nodes.map((node) => node.options?.outputVar).filter(Boolean) as string[] ]); + // 循环容器在运行时向子节点注入迭代变量,静态校验时视为已定义 + const LOOP_VARS: Record = { + logic_control_array_for_v3: ["item", "index", "value"], + logic_control_dictionary_for_v1: ["item", "index", "value"], + logic_control_count_for: ["index"] + }; + for (const node of flow.nodes) { + const vars = LOOP_VARS[node.componentId]; + if (vars) { + const custom = String(node.values?.count_index ?? "").trim(); + for (const name of vars) definedVars.add(name); + if (node.componentId === "logic_control_count_for" && /^[A-Za-z_]\w*$/.test(custom)) definedVars.add(custom); + } + } const variableRef = /\$\{\s*([A-Za-z_\u4e00-\u9fa5][\w\u4e00-\u9fa5]*)\s*(?:\.[A-Za-z_]\w*)?\s*\}/g; for (const node of flow.nodes) { const component = componentMap.get(node.componentId);