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 @@
-
+
{{ n.name }}{{ nodeState(f, n).text }}
@@ -102,6 +102,7 @@
:class="[nodeVisual(n), { active: selectedKey === n.key }, 'type-' + n.type]"
:style="{ left: n.x + 'px', top: n.y + 'px' }"
@pointerdown="startDrag($event, n)" @click.stop="selectNode(n)">
+ {{ nodeStep(n) }}
{{ typeLabel(n.type) }}
{{ nodeTitle(n) }}
@@ -756,6 +757,40 @@ function removeEdge(e) {
ElMessage.info('已删除这条连线')
}
+// 执行顺序:逐层取「依赖均已排入」的节点,层内保持数组原顺序——与后端 flows.js 的 execute() 取法一致。
+// 列表节点链与画布序号都按它展示,否则看起来会像「按添加顺序执行」。
+function execOrder(nodes) {
+ const list = nodes || []
+ if (list.length < 2) return [...list]
+ const keyOf = (n) => n.id || n.key
+ const ids = new Set(list.map(keyOf))
+ const done = new Set()
+ const out = []
+ let guard = 0
+ while (out.length < list.length && guard++ <= list.length + 1) {
+ const layer = list.filter(
+ (n) => !done.has(keyOf(n)) && (n.deps || []).every((d) => done.has(d) || !ids.has(d))
+ )
+ if (!layer.length) break
+ for (const n of layer) {
+ done.add(keyOf(n))
+ out.push(n)
+ }
+ }
+ // 兜底:环或脏依赖时不丢节点,保持原序追加
+ for (const n of list) if (!done.has(keyOf(n))) out.push(n)
+ return out
+}
+
+const stepMap = computed(() => {
+ const m = new Map()
+ execOrder(form.nodes).forEach((n, i) => m.set(n.key, i + 1))
+ return m
+})
+function nodeStep(n) {
+ return stepMap.value.get(n.key) || 0
+}
+
function autoLayout() {
const nodes = form.nodes
const byId = new Map(nodes.map((n) => [n.id || n.key, n]))
@@ -1093,6 +1128,11 @@ function nodeVisual(n) {
.fnode.ok { border-color: var(--good-line); }
.fnode.bad { border-color: var(--danger-line); background: var(--danger-soft); }
.fnode.skip { opacity: .6; }
+.fn-step {
+ position: absolute; left: -8px; top: -8px; width: 18px; height: 18px; border-radius: 50%;
+ background: var(--brand); color: #fff; font: 600 10px/18px var(--f-cn); text-align: center;
+ box-shadow: var(--sh-card); pointer-events: none;
+}
.fn-name { display: flex; align-items: center; gap: var(--space-1-5); min-width: 0; }
.fn-text { font: 600 12.5px/18px var(--f-cn); color: var(--t1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fn-type {