From a3ed22b8df3c588ff797f8789c11f48573c17e25 Mon Sep 17 00:00:00 2001 From: spudding <1115683088@qq.com> Date: Tue, 27 Oct 2026 13:53:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(electron-shell):=20=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E6=8C=89=E5=AE=9E=E9=99=85=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F=E5=B1=95=E7=A4=BA=EF=BC=8C=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=E6=8C=89=E6=B7=BB=E5=8A=A0=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 后端 normalizeNodes 保存时按执行序重排(拓扑层 + 层内原序,与 execute 取法一致) - 前端流程列表节点链改按执行序渲染,画布节点加执行序号徽标 --- desktop/electron-shell/electron/flows.js | 23 +++++++++- .../frontend/src/components/FlowPage.vue | 42 ++++++++++++++++++- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/desktop/electron-shell/electron/flows.js b/desktop/electron-shell/electron/flows.js index cea6c4a..30eb7a5 100644 --- a/desktop/electron-shell/electron/flows.js +++ b/desktop/electron-shell/electron/flows.js @@ -206,6 +206,27 @@ function topoLayers(nodes) { return layers; } +// 执行顺序:逐层取「依赖已全部成功」的节点,层内保持数组原顺序——与 execute() 的取法完全一致。 +// 保存时按它重排 nodes,数组顺序即执行顺序,前端列表/运行详情不必再猜。 +function execOrder(nodes) { + const done = new Set(); + const out = []; + let guard = 0; + while (out.length < nodes.length && guard++ <= nodes.length + 1) { + const layer = nodes.filter( + (n) => !done.has(n.id) && (n.deps || []).every((d) => done.has(d)) + ); + if (!layer.length) break; + for (const n of layer) { + done.add(n.id); + out.push(n); + } + } + // 理论到不了(保存前 topoLayers 已拦环/缺依赖),兜底不丢节点 + for (const n of nodes) if (!done.has(n.id)) out.push(n); + return out; +} + function normalizeNodes(raw) { if (!Array.isArray(raw) || !raw.length) throw new Error("流程至少需要 1 个节点"); if (raw.length > MAX_NODES) throw new Error(`单个流程最多 ${MAX_NODES} 个节点`); @@ -277,7 +298,7 @@ function normalizeNodes(raw) { } } topoLayers(nodes); // 有环直接抛 - return nodes; + return execOrder(nodes); } // 定时调度配置:与「定时任务」共用同一套 cron 解析与最小间隔(1 小时)约束 diff --git a/desktop/electron-shell/frontend/src/components/FlowPage.vue b/desktop/electron-shell/frontend/src/components/FlowPage.vue index 67bca9a..9a020bb 100644 --- a/desktop/electron-shell/frontend/src/components/FlowPage.vue +++ b/desktop/electron-shell/frontend/src/components/FlowPage.vue @@ -33,7 +33,7 @@
-