android-midscene-automation 1.1.7 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,82 +1,49 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, inject } from 'vue';
3
- import { BaseEdge, getBezierPath, type EdgeProps } from '@vue-flow/core';
4
- import { flowLineStyleKey, normalizeFlowLineStyle } from '../flow-appearance';
3
+ import { BaseEdge, type EdgeProps } from '@vue-flow/core';
4
+ import { flowLineStyleKey, normalizeFlowLineStyle, flowLayoutDirectionKey, normalizeFlowLayoutDirection } from '../flow-appearance';
5
5
  import type { FlowGraphNodeData } from '../flow-graph';
6
6
 
7
7
  const props = defineProps<EdgeProps>();
8
8
  const lineStyle = inject(flowLineStyleKey, computed(() => normalizeFlowLineStyle(undefined)));
9
+ const layoutDirection = inject(flowLayoutDirectionKey, computed(() => normalizeFlowLayoutDirection(undefined)));
9
10
 
10
- const targetData = computed(() => props.targetNode.data as FlowGraphNodeData | undefined);
11
-
12
- type Point = {
13
- x: number;
14
- y: number;
15
- };
16
-
17
- function linePath(points: Point[]) {
18
- if (points.length < 2) return '';
19
- const [start, ...rest] = points;
20
- return [
21
- `M ${start.x} ${start.y}`,
22
- ...rest.map((point) => `L ${point.x} ${point.y}`),
23
- ].join(' ');
24
- }
11
+ type Point = { x: number; y: number };
25
12
 
26
13
  const path = computed(() => {
27
- if (lineStyle.value === 'curved') {
28
- if (props.data?.merge && props.targetY > props.sourceY) {
29
- // 先沿分支向下,仅在汇合点上方的留白内弯曲,避免斜穿相邻节点。
30
- const bendY = Math.max(props.sourceY, props.targetY - 112);
31
- const controlY = (bendY + props.targetY) / 2;
32
- return [
33
- `M ${props.sourceX} ${props.sourceY}`,
34
- `L ${props.sourceX} ${bendY}`,
35
- `C ${props.sourceX} ${controlY} ${props.targetX} ${controlY} ${props.targetX} ${props.targetY}`,
36
- ].join(' ');
37
- }
38
- return getBezierPath({
39
- sourceX: props.sourceX, sourceY: props.sourceY, sourcePosition: props.sourcePosition,
40
- targetX: props.targetX, targetY: props.targetY, targetPosition: props.targetPosition,
41
- })[0];
42
- }
43
- const source = { x: props.sourceX, y: props.sourceY };
44
- const target = { x: props.targetX, y: props.targetY };
14
+ // 逻辑 y 轴始终沿流程前进,输出时再换成画布坐标。
15
+ const horizontal = layoutDirection.value === 'horizontal';
16
+ const source = horizontal ? { x: props.sourceY, y: props.sourceX } : { x: props.sourceX, y: props.sourceY };
17
+ const target = horizontal ? { x: props.targetY, y: props.targetX } : { x: props.targetX, y: props.targetY };
18
+ const point = ({ x, y }: Point) => horizontal ? `${y} ${x}` : `${x} ${y}`;
19
+ const linePath = (points: Point[]) => points.map((p, i) => `${i ? 'L' : 'M'} ${point(p)}`).join(' ');
45
20
  const deltaX = target.x - source.x;
46
21
  const deltaY = target.y - source.y;
22
+ const merge = props.data?.merge && deltaY > 0;
47
23
 
48
- if (props.data?.merge && deltaY > 0) {
49
- // 同一公共节点的入边共用横线高度,不能随各分支的长度变化。
50
- const joinY = target.y - 24;
51
- return linePath([source, { x: source.x, y: joinY }, { x: target.x, y: joinY }, target]);
24
+ if (lineStyle.value === 'curved') {
25
+ // 长汇入线先沿分支前进,留足弯曲空间后再汇合,避开中间卡片。
26
+ const bend = { x: source.x, y: merge ? Math.max(source.y, target.y - 160) : source.y };
27
+ const gap = target.y - bend.y;
28
+ const reach = gap > 0 ? Math.min(gap * 0.8, Math.max(gap * 0.5, Math.abs(deltaX) * 0.25)) : Math.max(40, Math.abs(gap) * 0.5);
29
+ return [
30
+ `M ${point(source)}`,
31
+ ...(bend.y !== source.y ? [`L ${point(bend)}`] : []),
32
+ `C ${point({ x: bend.x, y: bend.y + reach })} ${point({ x: target.x, y: target.y - reach })} ${point(target)}`,
33
+ ].join(' ');
52
34
  }
53
35
 
54
- if (targetData.value?.kind === 'branch') {
55
- const direction = deltaY >= 0 ? 1 : -1;
56
- const branchY = source.y + direction * Math.min(Math.max(Math.abs(deltaY) * 0.45, 18), 34);
57
- return linePath([
58
- source,
59
- { x: source.x, y: branchY },
60
- { x: target.x, y: branchY },
61
- target,
62
- ]);
36
+ if (merge) {
37
+ const joinY = target.y - 24;
38
+ return linePath([source, { x: source.x, y: joinY }, { x: target.x, y: joinY }, target]);
63
39
  }
64
-
65
- if (Math.abs(deltaX) < 2) {
66
- return `M ${source.x} ${source.y} L ${target.x} ${target.y}`;
40
+ if ((props.targetNode.data as FlowGraphNodeData | undefined)?.kind === 'branch') {
41
+ const branchY = source.y + (deltaY >= 0 ? 1 : -1) * Math.min(Math.max(Math.abs(deltaY) * 0.45, 18), 34);
42
+ return linePath([source, { x: source.x, y: branchY }, { x: target.x, y: branchY }, target]);
67
43
  }
68
-
69
- const verticalGap = Math.min(Math.max(Math.abs(deltaY) * 0.38, 28), 56);
70
- const splitY = deltaY >= 0
71
- ? source.y + verticalGap
72
- : source.y - verticalGap;
73
-
74
- return linePath([
75
- source,
76
- { x: source.x, y: splitY },
77
- { x: target.x, y: splitY },
78
- target,
79
- ]);
44
+ if (Math.abs(deltaX) < 2) return linePath([source, target]);
45
+ const splitY = source.y + (deltaY >= 0 ? 1 : -1) * Math.min(Math.max(Math.abs(deltaY) * 0.38, 28), 56);
46
+ return linePath([source, { x: source.x, y: splitY }, { x: target.x, y: splitY }, target]);
80
47
  });
81
48
  </script>
82
49
 
@@ -163,7 +163,7 @@ function patchSelector(patch: Partial<AppiumSelector>) {
163
163
 
164
164
  <template>
165
165
  <div class="appium-flow-editor">
166
- <el-form label-position="top" size="small">
166
+ <el-form class="appium-flow-editor__form" label-position="left" label-width="104px" size="small">
167
167
  <LongPressSettings v-if="step.type === 'longPress'" :step="step" :disabled="disabled" @update="patchStep" />
168
168
  <el-form-item v-if="['waitActivity', 'launchApp', 'stopApp', 'clearAppData'].includes(step.type)" :label="step.type === 'waitActivity' ? '目标 Activity' : '目标 APP 包名'">
169
169
  <el-input :model-value="step.value || ''" :disabled="disabled" @update:model-value="patchStep({ value: String($event) })" />
@@ -458,19 +458,55 @@ function patchSelector(patch: Partial<AppiumSelector>) {
458
458
  </template>
459
459
 
460
460
  <style scoped>
461
+ .appium-flow-editor { --node-editor-gap: 12px; padding: 12px; }
462
+ .appium-flow-editor__form { display: grid; gap: var(--node-editor-gap); }
463
+ /* 高度动画会逐帧触发整张流程重排,子选项直接展开以保持编辑响应。 */
464
+ .appium-flow-editor :deep(.el-collapse-item__wrap) { transition: none; }
465
+ .appium-flow-editor :deep(.appium-flow-editor__section) { display: grid; gap: var(--node-editor-gap); }
466
+ .appium-flow-editor :deep(.el-collapse .el-collapse-item__content) {
467
+ display: grid;
468
+ gap: var(--node-editor-gap);
469
+ padding: 12px;
470
+ }
461
471
  .appium-flow-editor__fallback {
462
472
  display: grid;
463
- gap: 10px;
464
- margin-top: 8px;
473
+ gap: var(--node-editor-gap);
465
474
  padding-top: 12px;
466
475
  border-top: 1px solid var(--el-border-color-lighter);
467
476
  }
468
477
 
469
- .appium-flow-editor :deep(.el-form-item) { margin-bottom: 10px; }
470
-
471
- .appium-flow-editor__fallback :deep(.el-form-item) {
472
- margin-bottom: 0;
478
+ .appium-flow-editor :deep(.el-form-item),
479
+ .appium-flow-editor :deep(.ai-recognition-settings .el-form-item) { min-width: 0; margin: 0; }
480
+ .appium-flow-editor :deep(.el-form-item.is-error) { margin-bottom: 8px; }
481
+ .appium-flow-editor :deep(.el-form-item:has(> .el-form-item__label)) {
482
+ display: grid;
483
+ grid-template-columns: 100px minmax(0, 1fr);
484
+ align-items: start;
485
+ column-gap: 8px;
486
+ }
487
+ .appium-flow-editor :deep(.el-form-item > .el-form-item__label) {
488
+ justify-content: flex-start;
489
+ width: auto !important;
490
+ height: auto;
491
+ min-height: 28px;
492
+ margin: 0;
493
+ padding: 5px 0;
494
+ color: var(--ui-text-secondary);
495
+ font-size: 12px;
496
+ line-height: 18px;
497
+ overflow-wrap: anywhere;
473
498
  }
499
+ .appium-flow-editor :deep(.el-form-item > .el-form-item__content) { min-width: 0; margin-left: 0 !important; }
500
+ .appium-flow-editor :deep(.el-input-number),
501
+ .appium-flow-editor :deep(.el-select) { width: 100%; }
502
+ .appium-flow-editor :deep(.appium-flow-editor__grid),
503
+ .appium-flow-editor :deep(.ai-recognition-settings__grid) { grid-template-columns: minmax(0, 1fr); gap: var(--node-editor-gap); }
504
+ .appium-flow-editor :deep(.el-input__wrapper),
505
+ .appium-flow-editor :deep(.el-select__wrapper),
506
+ .appium-flow-editor :deep(.el-textarea__inner) { background: var(--ui-bg-soft); box-shadow: inset 0 0 0 1px var(--ui-border); }
507
+ .appium-flow-editor :deep(.el-form-item:has(.el-textarea)) { display: block; }
508
+ .appium-flow-editor :deep(.el-radio-group) { width: 100%; }
509
+ .appium-flow-editor :deep(.el-radio-button__inner) { padding: 5px 8px; font-size: 12px; }
474
510
 
475
511
  .appium-flow-editor__fallback-alert {
476
512
  padding: 8px 12px;
@@ -483,10 +519,10 @@ function patchSelector(patch: Partial<AppiumSelector>) {
483
519
 
484
520
  .appium-flow-editor__groups {
485
521
  overflow: hidden;
486
- margin-top: 8px;
522
+ margin: 0;
487
523
  border: 1px solid var(--el-border-color-lighter);
488
524
  border-radius: 10px;
489
- background: #fff;
525
+ background: var(--ui-surface);
490
526
  }
491
527
 
492
528
  .appium-flow-editor__groups :deep(.el-collapse-item__header) {
@@ -497,7 +533,6 @@ function patchSelector(patch: Partial<AppiumSelector>) {
497
533
  }
498
534
 
499
535
  .appium-flow-editor__groups :deep(.el-collapse-item__wrap) { border-bottom: 0; }
500
- .appium-flow-editor__groups :deep(.el-collapse-item__content) { padding: 8px 10px 2px; }
501
536
  .appium-flow-editor__group-title { display: flex; align-items: center; justify-content: space-between; min-width: 0; width: 100%; padding-right: 8px; gap: 8px; }
502
537
  .appium-flow-editor__group-title strong { flex: none; color: var(--ui-text); font-size: 12px; }
503
538
  .appium-flow-editor__group-title small { min-width: 0; overflow: hidden; color: var(--ui-text-muted); font-size: 11px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
@@ -23,7 +23,7 @@ function changeCoordinate(key: 'centerX' | 'centerY', value: number | undefined)
23
23
  </script>
24
24
 
25
25
  <template>
26
- <div>
26
+ <div class="appium-flow-editor__section">
27
27
  <el-form-item label="长按方式">
28
28
  <el-radio-group :model-value="mode" :disabled="disabled" @update:model-value="changeMode($event as AppiumRecordedStep['longPressMode'])">
29
29
  <el-radio-button value="element">长按元素</el-radio-button>
@@ -241,7 +241,13 @@ async function deleteSelectedNodes() {
241
241
  finally { deleting.value = false; }
242
242
  }
243
243
 
244
- watch(() => props.steps, () => { if (copyMode.value) cancelCopyMode(); });
244
+ watch(() => props.steps, (steps, previous) => {
245
+ if (copyMode.value) cancelCopyMode();
246
+ if (expandedStepIndex.value === null) return;
247
+ const id = previous[expandedStepIndex.value]?.id;
248
+ const index = steps.findIndex(step => step.id === id);
249
+ expandedStepIndex.value = index < 0 ? null : index;
250
+ });
245
251
 
246
252
  function resetMainFlowPosition() {
247
253
  mainResetViewToken.value += 1;
@@ -31,3 +31,40 @@ export const flowLineStyleKey: InjectionKey<Readonly<Ref<FlowLineStyle>>> = Symb
31
31
  export function normalizeFlowLineStyle(value: unknown): FlowLineStyle {
32
32
  return value === 'straight' ? 'straight' : 'curved';
33
33
  }
34
+
35
+ export type FlowLayoutDirection = 'vertical' | 'horizontal';
36
+ export const flowLayoutDirectionKey: InjectionKey<Readonly<Ref<FlowLayoutDirection>>> = Symbol('flowLayoutDirection');
37
+
38
+ export function normalizeFlowLayoutDirection(value: unknown): FlowLayoutDirection {
39
+ return value === 'horizontal' ? 'horizontal' : 'vertical';
40
+ }
41
+
42
+ export const DEFAULT_FLOW_NODE_COLOR = '#ffffff';
43
+ export const DEFAULT_FLOW_NODE_BORDER_COLOR = '#dfe8f3';
44
+ export const flowNodeColorKey: InjectionKey<Readonly<Ref<string>>> = Symbol('flowNodeColor');
45
+ export const flowNodeBorderColorKey: InjectionKey<Readonly<Ref<string>>> = Symbol('flowNodeBorderColor');
46
+
47
+ export function normalizeFlowNodeColor(value: unknown) {
48
+ return normalizeFlowColor(value, DEFAULT_FLOW_NODE_COLOR);
49
+ }
50
+ export function normalizeFlowNodeBorderColor(value: unknown) {
51
+ return normalizeFlowColor(value, DEFAULT_FLOW_NODE_BORDER_COLOR);
52
+ }
53
+
54
+ export const FLOW_APPEARANCE_THEMES = [
55
+ { id: 'default', name: '默认浅灰', colors: { flowBackgroundColor: DEFAULT_FLOW_BACKGROUND, flowNodeColor: DEFAULT_FLOW_NODE_COLOR, flowNodeBorderColor: DEFAULT_FLOW_NODE_BORDER_COLOR, flowLineColor: DEFAULT_FLOW_LINE_COLOR } },
56
+ { id: 'blue', name: '雾蓝', colors: { flowBackgroundColor: '#eaf2fb', flowNodeColor: '#f6faff', flowNodeBorderColor: '#a8c1df', flowLineColor: '#6385b0' } },
57
+ { id: 'mint', name: '薄荷', colors: { flowBackgroundColor: '#e9f3ee', flowNodeColor: '#f5fcf8', flowNodeBorderColor: '#a2c5b2', flowLineColor: '#5d8d74' } },
58
+ { id: 'apricot', name: '暖杏', colors: { flowBackgroundColor: '#f8f0e6', flowNodeColor: '#fffaf3', flowNodeBorderColor: '#dcc3a2', flowLineColor: '#ac8256' } },
59
+ { id: 'violet', name: '浅紫', colors: { flowBackgroundColor: '#f0ecf8', flowNodeColor: '#faf8ff', flowNodeBorderColor: '#c4b4df', flowLineColor: '#9175b3' } },
60
+ { id: 'graphite', name: '石墨', colors: { flowBackgroundColor: '#191c22', flowNodeColor: '#292e38', flowNodeBorderColor: '#535e70', flowLineColor: '#a9a0d8' } },
61
+ ];
62
+ export type FlowAppearanceTheme = typeof FLOW_APPEARANCE_THEMES[number];
63
+
64
+ export function flowNodeTextColors(value: unknown) {
65
+ const color = normalizeFlowNodeColor(value);
66
+ const rgb = [1, 3, 5].map(index => parseInt(color.slice(index, index + 2), 16) / 255)
67
+ .map(channel => channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4);
68
+ const dark = rgb[0] * 0.2126 + rgb[1] * 0.7152 + rgb[2] * 0.0722 < 0.179;
69
+ return { dark, text: dark ? '#f1f5f9' : '#0f172a', muted: dark ? '#b7c1d1' : '#64748b' };
70
+ }
@@ -1,6 +1,7 @@
1
1
  import { Position, type Edge, type Node } from '@vue-flow/core';
2
2
  import * as dagre from '@dagrejs/dagre';
3
3
  import type { AppiumRecordedStep } from './types';
4
+ import type { FlowLayoutDirection } from './flow-appearance';
4
5
  import { defaultFlowKind as defaultKind, flowBranchLabel, isBooleanCondition } from './flow-labels';
5
6
 
6
7
  type DagreApi = typeof dagre;
@@ -140,6 +141,7 @@ type StepItem = {
140
141
  };
141
142
 
142
143
  type BuildFlowGraphOptions = {
144
+ layoutDirection?: FlowLayoutDirection;
143
145
  aiRecognitionModelConfigured?: boolean;
144
146
  expandedStepIndex: number | null;
145
147
  selectedCopyIndexes: number[];
@@ -307,7 +309,15 @@ export function buildFlowGraph(
307
309
  steps: AppiumRecordedStep[],
308
310
  options: BuildFlowGraphOptions,
309
311
  ) {
312
+ const horizontal = options.layoutDirection === 'horizontal';
313
+ const branchMinWidth = horizontal ? FLOW_STEP_NODE_HEIGHT : FLOW_STEP_NODE_WIDTH;
314
+ const branchMinSpread = horizontal ? 100 : FLOW_BRANCH_MIN_SPREAD;
310
315
  const items = steps.map((step, index) => ({ step, index }));
316
+ const stepNodeHeight = ({ step, index }: StepItem) => {
317
+ const estimated = estimateStepNodeHeight(options.labelStep(step), step.type === 'aiRecognition' ? 3 : undefined)
318
+ + (options.expandedStepIndex === index ? FLOW_EXPANDED_NODE_HEIGHT : 0);
319
+ return Math.max(FLOW_STEP_NODE_HEIGHT, Math.ceil(options.measuredNodeHeights?.[nodeIdForStep(step)] || estimated));
320
+ };
311
321
  const nodes: FlowGraphNode[] = [];
312
322
  const links: Link[] = [];
313
323
  const layoutLinks: Link[] = [];
@@ -321,26 +331,26 @@ export function buildFlowGraph(
321
331
  if (cached) return cached;
322
332
  if (measuringBranches.has(condition.id)) {
323
333
  return {
324
- yesWidth: FLOW_STEP_NODE_WIDTH,
325
- noWidth: FLOW_STEP_NODE_WIDTH,
326
- centerGap: FLOW_BRANCH_MIN_SPREAD * 2,
327
- totalWidth: FLOW_BRANCH_MIN_SPREAD * 2 + FLOW_STEP_NODE_WIDTH,
334
+ yesWidth: branchMinWidth,
335
+ noWidth: branchMinWidth,
336
+ centerGap: branchMinSpread * 2,
337
+ totalWidth: branchMinSpread * 2 + branchMinWidth,
328
338
  };
329
339
  }
330
340
 
331
341
  measuringBranches.add(condition.id);
332
342
  const branchWidth = (branch: FlowBranch) => Math.max(
333
- FLOW_STEP_NODE_WIDTH,
334
- ...directBranchItems(items, condition.id, branch).map(({ step }) => (
335
- defaultKind(step) === 'condition'
336
- ? conditionBranchLayout(step).totalWidth
337
- : FLOW_STEP_NODE_WIDTH
343
+ branchMinWidth,
344
+ ...directBranchItems(items, condition.id, branch).map((item) => (
345
+ defaultKind(item.step) === 'condition'
346
+ ? Math.max(conditionBranchLayout(item.step).totalWidth, horizontal ? stepNodeHeight(item) : branchMinWidth)
347
+ : horizontal ? stepNodeHeight(item) : branchMinWidth
338
348
  )),
339
349
  );
340
350
  const yesWidth = branchWidth('yes');
341
351
  const noWidth = branchWidth('no');
342
352
  const centerGap = Math.max(
343
- FLOW_BRANCH_MIN_SPREAD * 2,
353
+ branchMinSpread * 2,
344
354
  yesWidth / 2 + noWidth / 2 + FLOW_BRANCH_SUBTREE_GAP,
345
355
  );
346
356
  const sideExtent = Math.max(
@@ -351,7 +361,7 @@ export function buildFlowGraph(
351
361
  yesWidth,
352
362
  noWidth,
353
363
  centerGap,
354
- totalWidth: Math.max(FLOW_STEP_NODE_WIDTH, sideExtent * 2),
364
+ totalWidth: Math.max(branchMinWidth, sideExtent * 2),
355
365
  };
356
366
  measuringBranches.delete(condition.id);
357
367
  branchLayouts.set(condition.id, layout);
@@ -363,12 +373,14 @@ export function buildFlowGraph(
363
373
  .forEach(({ step }) => conditionBranchLayout(step));
364
374
 
365
375
  const addNode = (node: FlowGraphNode) => {
376
+ // 在逻辑纵向坐标中复用分支、汇合和避让算法,横向布局交换节点尺寸后计算。
377
+ const width = Number(node.width) || FLOW_STEP_NODE_WIDTH;
378
+ const height = Number(node.height) || FLOW_STEP_NODE_HEIGHT;
366
379
  nodes.push({
367
380
  ...node,
368
- dimensions: {
369
- width: Number(node.width) || FLOW_STEP_NODE_WIDTH,
370
- height: Number(node.height) || FLOW_STEP_NODE_HEIGHT,
371
- },
381
+ width: horizontal ? height : width,
382
+ height: horizontal ? width : height,
383
+ dimensions: { width: horizontal ? height : width, height: horizontal ? width : height },
372
384
  } as FlowGraphNode);
373
385
  };
374
386
  const addVisibleLink = (source: string, target: string, branch?: FlowBranch) => {
@@ -427,14 +439,7 @@ export function buildFlowGraph(
427
439
  const label = options.labelStep(item.step);
428
440
  // 字数估算仅用于首次布局,不强制卡片高度;实际换行由浏览器决定。
429
441
  const cardMinHeight = FLOW_STEP_NODE_HEIGHT;
430
- const estimatedCardHeight = estimateStepNodeHeight(
431
- label,
432
- item.step.type === 'aiRecognition' ? 3 : undefined,
433
- );
434
- const estimatedNodeHeight = options.expandedStepIndex === item.index
435
- ? estimatedCardHeight + FLOW_EXPANDED_NODE_HEIGHT
436
- : estimatedCardHeight;
437
- const nodeHeight = Math.max(cardMinHeight, Math.ceil(options.measuredNodeHeights?.[id] || estimatedNodeHeight));
442
+ const nodeHeight = stepNodeHeight(item);
438
443
  addNode({
439
444
  id,
440
445
  type: 'flow-node',
@@ -790,7 +795,7 @@ export function buildFlowGraph(
790
795
  if (joinOwner && target.id !== joinOwner) {
791
796
  const incoming = links.filter((edge) => edge.target === target.id).map((edge) => nodeById.get(edge.source)!).filter(Boolean);
792
797
  if (incoming.length) {
793
- target.position.y = Math.round(Math.max(...incoming.map((node) => node.position.y + nodeHeight(node))) + FLOW_STANDARD_LINE_GAP * 4);
798
+ target.position.y = Math.round(Math.max(...incoming.map((node) => node.position.y + nodeHeight(node))) + FLOW_STANDARD_LINE_GAP * 8);
794
799
  const incomingCenters = incoming.map(centerX);
795
800
  setCenterX(target, (Math.min(...incomingCenters) + Math.max(...incomingCenters)) / 2);
796
801
  }
@@ -806,7 +811,7 @@ export function buildFlowGraph(
806
811
  let x = centerX(source);
807
812
  if (target.data.kind === 'branch') {
808
813
  const conditionId = steps[target.data.conditionIndex].id;
809
- const spread = (branchLayouts.get(conditionId)?.centerGap || FLOW_BRANCH_MIN_SPREAD * 2) / 2;
814
+ const spread = (branchLayouts.get(conditionId)?.centerGap || branchMinSpread * 2) / 2;
810
815
  x += target.data.branch === 'yes' ? -spread : spread;
811
816
  }
812
817
  setCenterX(target, x);
@@ -838,6 +843,17 @@ export function buildFlowGraph(
838
843
  data: { branch: link.branch, merge: joins.has(link.target) },
839
844
  }));
840
845
 
846
+ if (horizontal) {
847
+ positionedNodes.forEach((node) => {
848
+ node.position = { x: node.position.y, y: node.position.x };
849
+ const width = node.width;
850
+ node.width = node.height;
851
+ node.height = width;
852
+ Object.assign(node, { dimensions: { width: Number(node.width), height: Number(node.height) } });
853
+ node.sourcePosition = Position.Right;
854
+ node.targetPosition = Position.Left;
855
+ });
856
+ }
841
857
  return { nodes: positionedNodes, edges };
842
858
  }
843
859
 
@@ -68,8 +68,16 @@ defineEmits<{
68
68
  </section>
69
69
 
70
70
  <section class="appium-config-section" aria-labelledby="appium-editor-title">
71
- <header class="appium-section-heading"><div><h2 id="appium-editor-title">流程编辑器</h2><p>调整流程画布颜色、连接线颜色和曲直样式。</p></div></header>
72
- <FlowAppearanceSettings v-model="configForm.appium.flowBackgroundColor" v-model:line-color="configForm.appium.flowLineColor" v-model:line-style="configForm.appium.flowLineStyle" />
71
+ <header class="appium-section-heading"><div><h2 id="appium-editor-title">流程编辑器</h2><p>选择流程主题,调整画布、节点和连接线颜色,以及横纵布局。</p></div></header>
72
+ <FlowAppearanceSettings
73
+ v-model="configForm.appium.flowBackgroundColor"
74
+ v-model:node-color="configForm.appium.flowNodeColor"
75
+ v-model:node-border-color="configForm.appium.flowNodeBorderColor"
76
+ v-model:line-color="configForm.appium.flowLineColor"
77
+ v-model:line-style="configForm.appium.flowLineStyle"
78
+ v-model:layout-direction="configForm.appium.flowLayoutDirection"
79
+ @apply-theme="Object.assign(configForm.appium, $event.colors)"
80
+ />
73
81
  </section>
74
82
  </div>
75
83
  </template>