android-midscene-automation 1.1.5 → 1.1.7
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.
- package/CHANGELOG.md +13 -0
- package/README.md +13 -0
- package/package.json +1 -1
- package/server/appium-config.test.ts +5 -1
- package/server/appium-recorder/ai-recognition.ts +9 -0
- package/server/appium-recorder/appium-runner.ts +13 -2
- package/server/appium-recorder/element-tap.test.ts +61 -0
- package/server/appium-recorder/request-timeout.test.ts +34 -0
- package/server/appium-recorder/request-timeout.ts +7 -3
- package/server/config.ts +7 -3
- package/src/App.vue +1 -0
- package/src/appium-recorder/AppiumPage.vue +9 -4
- package/src/appium-recorder/components/AiRecognitionSettings.vue +141 -84
- package/src/appium-recorder/components/FlowCanvas.vue +39 -1
- package/src/appium-recorder/components/FlowNodeCard.vue +11 -1
- package/src/appium-recorder/components/FlowRoundedEdge.vue +20 -2
- package/src/appium-recorder/components/FlowStepEditor.vue +114 -85
- package/src/appium-recorder/components/LoopSettings.vue +12 -10
- package/src/appium-recorder/components/NestedConditionBranches.vue +5 -1
- package/src/appium-recorder/components/RecordedSteps.vue +14 -0
- package/src/appium-recorder/components/TextClickSettings.vue +11 -11
- package/src/appium-recorder/components/VariableExtractionSettings.vue +6 -4
- package/src/appium-recorder/flow-appearance.ts +9 -2
- package/src/appium-recorder/flow-graph.ts +13 -7
- package/src/components/config/AppiumConfigPanel.vue +2 -2
- package/src/components/config/FlowAppearanceSettings.vue +12 -5
- package/src/config/use-model-config.ts +2 -1
- package/src/pages/ConfigPage.vue +6 -6
- package/src/style.css +28 -18
- package/src/types.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed } from 'vue';
|
|
2
|
+
import { computed, ref } from 'vue';
|
|
3
3
|
import CoordinatePointPicker from './CoordinatePointPicker.vue';
|
|
4
4
|
import type { AppiumRecordedStep, AppiumSelector } from '../types';
|
|
5
5
|
import { normalizeVisualChangeConfig } from '../visual-change';
|
|
@@ -51,6 +51,16 @@ const invalidTapCoordinates = computed(() => (
|
|
|
51
51
|
&& Number(props.step.fallback?.centerX) === 0
|
|
52
52
|
&& Number(props.step.fallback?.centerY) === 0
|
|
53
53
|
));
|
|
54
|
+
const editorSections = ref<string[]>([]);
|
|
55
|
+
const selectorSummary = computed(() => {
|
|
56
|
+
const selector = props.step.selector;
|
|
57
|
+
if (!selector) return '未设置';
|
|
58
|
+
const value = selector.value?.trim() || '未填写';
|
|
59
|
+
return `${selector.strategy} · ${value}${props.step.contextSelector ? ' · 含父级' : ''}`;
|
|
60
|
+
});
|
|
61
|
+
const supportsTimeout = computed(() => ![
|
|
62
|
+
'delay', 'longPress', 'stopApp', 'log', 'openGallery', 'endFlow', 'loop', 'breakLoop', 'continueLoop', 'aiRecognition',
|
|
63
|
+
].includes(props.step.type));
|
|
54
64
|
|
|
55
65
|
function defaultKind(): FlowKind {
|
|
56
66
|
return defaultFlowKind(props.step);
|
|
@@ -154,55 +164,27 @@ function patchSelector(patch: Partial<AppiumSelector>) {
|
|
|
154
164
|
<template>
|
|
155
165
|
<div class="appium-flow-editor">
|
|
156
166
|
<el-form label-position="top" size="small">
|
|
157
|
-
<el-form-item label="节点名称">
|
|
158
|
-
<el-input
|
|
159
|
-
:model-value="step.label"
|
|
160
|
-
:disabled="disabled"
|
|
161
|
-
@update:model-value="patchStep({ label: String($event) })"
|
|
162
|
-
/>
|
|
163
|
-
</el-form-item>
|
|
164
|
-
<el-form-item label="备注">
|
|
165
|
-
<el-input
|
|
166
|
-
:model-value="step.note || ''"
|
|
167
|
-
:disabled="disabled"
|
|
168
|
-
maxlength="100"
|
|
169
|
-
placeholder="例如:登录按钮、账号输入框"
|
|
170
|
-
@update:model-value="patchStep({ note: String($event) || undefined })"
|
|
171
|
-
/>
|
|
172
|
-
</el-form-item>
|
|
173
|
-
<div>
|
|
174
|
-
<el-form-item v-if="step.type === 'aiRecognition'">
|
|
175
|
-
<el-checkbox :model-value="step.aiTimeoutEnabled === true" :disabled="disabled" @update:model-value="patchStep({ aiTimeoutEnabled: $event === true })">启用超时</el-checkbox>
|
|
176
|
-
</el-form-item>
|
|
177
|
-
<el-form-item v-if="!['longPress', 'stopApp', 'log', 'openGallery', 'endFlow', 'loop', 'breakLoop', 'continueLoop'].includes(step.type) && (step.type !== 'aiRecognition' || step.aiTimeoutEnabled === true)" :label="step.type === 'aiRecognition' && step.aiObservation ? '模型请求超时 ms' : '超时时间 ms'">
|
|
178
|
-
<el-input-number
|
|
179
|
-
:model-value="step.timeoutMs ?? (step.type === 'delay' ? 1000 : DEFAULT_NODE_TIMEOUT_MS)"
|
|
180
|
-
:disabled="disabled"
|
|
181
|
-
:min="0"
|
|
182
|
-
:max="999999"
|
|
183
|
-
:step="1000"
|
|
184
|
-
controls-position="right"
|
|
185
|
-
@update:model-value="patchTimeout($event)"
|
|
186
|
-
/>
|
|
187
|
-
</el-form-item>
|
|
188
|
-
<BranchTimeoutSettings v-if="defaultKind() === 'condition' && (step.type !== 'aiRecognition' || step.aiTimeoutEnabled === true)" :step="step" :disabled="disabled" @update="patchStep({ timeoutBranch: $event })" />
|
|
189
|
-
</div>
|
|
190
167
|
<LongPressSettings v-if="step.type === 'longPress'" :step="step" :disabled="disabled" @update="patchStep" />
|
|
191
168
|
<el-form-item v-if="['waitActivity', 'launchApp', 'stopApp', 'clearAppData'].includes(step.type)" :label="step.type === 'waitActivity' ? '目标 Activity' : '目标 APP 包名'">
|
|
192
169
|
<el-input :model-value="step.value || ''" :disabled="disabled" @update:model-value="patchStep({ value: String($event) })" />
|
|
193
170
|
</el-form-item>
|
|
171
|
+
<el-form-item v-if="step.type === 'delay'" label="延时时长 ms">
|
|
172
|
+
<el-input-number :model-value="step.timeoutMs ?? 1000" :disabled="disabled" :min="0" :max="999999" :step="1000" controls-position="right" @update:model-value="patchTimeout($event)" />
|
|
173
|
+
</el-form-item>
|
|
194
174
|
<template v-if="step.type === 'pinch'">
|
|
195
175
|
<el-form-item label="缩放方向">
|
|
196
176
|
<el-select :model-value="step.pinch?.direction || 'out'" :disabled="disabled" @update:model-value="patchPinch({ direction: $event })">
|
|
197
177
|
<el-option label="放大" value="out" /><el-option label="缩小" value="in" />
|
|
198
178
|
</el-select>
|
|
199
179
|
</el-form-item>
|
|
200
|
-
<
|
|
201
|
-
<el-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
<el-
|
|
205
|
-
|
|
180
|
+
<div class="appium-flow-editor__grid">
|
|
181
|
+
<el-form-item v-for="axis in (['centerX', 'centerY'] as const)" :key="axis" :label="axis === 'centerX' ? '中心 X' : '中心 Y'">
|
|
182
|
+
<el-input-number :model-value="step.pinch?.[axis] ?? 0" :disabled="disabled" :min="0" :max="99999" :precision="0" controls-position="right" @update:model-value="patchPinch({ [axis]: $event ?? 0 })" />
|
|
183
|
+
</el-form-item>
|
|
184
|
+
<el-form-item label="缩放比例">
|
|
185
|
+
<el-input-number :model-value="step.pinch?.percent ?? 0.5" :disabled="disabled" :min="0.01" :max="1" :step="0.05" controls-position="right" @update:model-value="patchPinch({ percent: $event ?? 0.5 })" />
|
|
186
|
+
</el-form-item>
|
|
187
|
+
</div>
|
|
206
188
|
</template>
|
|
207
189
|
<StageLogSettings v-if="step.type === 'log'" :step="step" :disabled="disabled" @update="patchStep" />
|
|
208
190
|
<VariableExtractionSettings v-if="step.type === 'extractVariable'" :step="step" :disabled="disabled" @update="patchStep" />
|
|
@@ -210,7 +192,25 @@ function patchSelector(patch: Partial<AppiumSelector>) {
|
|
|
210
192
|
<LoopSettings v-if="step.type === 'loop'" :step="step" :disabled="disabled" @update="patchStep" />
|
|
211
193
|
<BreakLoopSettings v-if="step.type === 'breakLoop' || step.type === 'continueLoop'" :step="step" :steps="steps" :disabled="disabled" :mode="step.type === 'continueLoop' ? 'continue' : 'break'" @update="patchStep" />
|
|
212
194
|
<TextClickSettings v-if="step.type === 'textClick'" :step="step" :disabled="disabled" @update="patchStep" />
|
|
213
|
-
<AiRecognitionSettings v-if="step.type === 'aiRecognition'" :step="step" :steps="steps" :disabled="disabled" @update="patchStep"
|
|
195
|
+
<AiRecognitionSettings v-if="step.type === 'aiRecognition'" :step="step" :steps="steps" :disabled="disabled" @update="patchStep">
|
|
196
|
+
<template #other>
|
|
197
|
+
<el-form-item label="节点名称">
|
|
198
|
+
<el-input :model-value="step.label" :disabled="disabled" @update:model-value="patchStep({ label: String($event) })" />
|
|
199
|
+
</el-form-item>
|
|
200
|
+
<el-form-item label="备注">
|
|
201
|
+
<el-input :model-value="step.note || ''" :disabled="disabled" maxlength="100" placeholder="例如:播放画面检测" @update:model-value="patchStep({ note: String($event) || undefined })" />
|
|
202
|
+
</el-form-item>
|
|
203
|
+
<el-form-item>
|
|
204
|
+
<el-checkbox :model-value="step.aiTimeoutEnabled === true" :disabled="disabled" @update:model-value="patchStep({ aiTimeoutEnabled: $event === true })">启用超时</el-checkbox>
|
|
205
|
+
</el-form-item>
|
|
206
|
+
<template v-if="step.aiTimeoutEnabled === true">
|
|
207
|
+
<el-form-item :label="step.aiObservation ? '模型请求超时 ms' : '超时时间 ms'">
|
|
208
|
+
<el-input-number :model-value="step.timeoutMs ?? DEFAULT_NODE_TIMEOUT_MS" :disabled="disabled" :min="0" :max="999999" :step="1000" controls-position="right" @update:model-value="patchTimeout($event)" />
|
|
209
|
+
</el-form-item>
|
|
210
|
+
<BranchTimeoutSettings v-if="defaultKind() === 'condition'" :step="step" :disabled="disabled" @update="patchStep({ timeoutBranch: $event })" />
|
|
211
|
+
</template>
|
|
212
|
+
</template>
|
|
213
|
+
</AiRecognitionSettings>
|
|
214
214
|
<el-form-item
|
|
215
215
|
v-if="step.type === 'input' || step.type === 'inputIfExists' || step.type === 'assertText'"
|
|
216
216
|
label="文本内容"
|
|
@@ -363,50 +363,39 @@ function patchSelector(patch: Partial<AppiumSelector>) {
|
|
|
363
363
|
/>
|
|
364
364
|
</el-form-item>
|
|
365
365
|
</div>
|
|
366
|
-
<
|
|
367
|
-
<el-
|
|
368
|
-
<
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
<el-option label="xpath" value="xpath" />
|
|
400
|
-
</el-select>
|
|
401
|
-
</el-form-item>
|
|
402
|
-
<el-form-item label="父级上下文值">
|
|
403
|
-
<el-input
|
|
404
|
-
:model-value="step.contextSelector?.value || ''"
|
|
405
|
-
:disabled="disabled || !step.contextSelector"
|
|
406
|
-
@update:model-value="patchStep({ contextSelector: { ...(step.contextSelector || { strategy: 'xpath' }), value: String($event) } })"
|
|
407
|
-
/>
|
|
408
|
-
</el-form-item>
|
|
409
|
-
</div>
|
|
366
|
+
<el-collapse v-if="showSelector" v-model="editorSections" class="appium-flow-editor__groups">
|
|
367
|
+
<el-collapse-item name="selector">
|
|
368
|
+
<template #title>
|
|
369
|
+
<span class="appium-flow-editor__group-title"><strong>组件定位</strong><small>{{ selectorSummary }}</small></span>
|
|
370
|
+
</template>
|
|
371
|
+
<div v-if="step.selector" class="appium-flow-editor__grid">
|
|
372
|
+
<el-form-item label="Selector 类型">
|
|
373
|
+
<el-select :model-value="step.selector.strategy" :disabled="disabled" @update:model-value="patchSelector({ strategy: $event as AppiumSelector['strategy'] })">
|
|
374
|
+
<el-option label="accessibility id" value="accessibilityId" />
|
|
375
|
+
<el-option label="id" value="id" />
|
|
376
|
+
<el-option label="android uiAutomator" value="androidUiAutomator" />
|
|
377
|
+
<el-option label="xpath" value="xpath" />
|
|
378
|
+
</el-select>
|
|
379
|
+
</el-form-item>
|
|
380
|
+
<el-form-item label="Selector 值">
|
|
381
|
+
<el-input :model-value="step.selector.value || ''" :disabled="disabled" @update:model-value="patchSelector({ value: String($event) })" />
|
|
382
|
+
</el-form-item>
|
|
383
|
+
</div>
|
|
384
|
+
<div class="appium-flow-editor__grid">
|
|
385
|
+
<el-form-item label="父级上下文类型">
|
|
386
|
+
<el-select :model-value="step.contextSelector?.strategy || ''" :disabled="disabled" clearable placeholder="不使用父级" @update:model-value="patchStep({ contextSelector: $event ? { ...(step.contextSelector || { value: '' }), strategy: $event as AppiumSelector['strategy'] } : undefined })">
|
|
387
|
+
<el-option label="accessibility id" value="accessibilityId" />
|
|
388
|
+
<el-option label="id" value="id" />
|
|
389
|
+
<el-option label="android uiAutomator" value="androidUiAutomator" />
|
|
390
|
+
<el-option label="xpath" value="xpath" />
|
|
391
|
+
</el-select>
|
|
392
|
+
</el-form-item>
|
|
393
|
+
<el-form-item label="父级上下文值">
|
|
394
|
+
<el-input :model-value="step.contextSelector?.value || ''" :disabled="disabled || !step.contextSelector" @update:model-value="patchStep({ contextSelector: { ...(step.contextSelector || { strategy: 'xpath' }), value: String($event) } })" />
|
|
395
|
+
</el-form-item>
|
|
396
|
+
</div>
|
|
397
|
+
</el-collapse-item>
|
|
398
|
+
</el-collapse>
|
|
410
399
|
<div v-if="defaultKind() === 'condition' && step.type !== 'loop' && !isBooleanCondition(step)" class="appium-flow-editor__grid">
|
|
411
400
|
<el-form-item label="指定文本(可选)">
|
|
412
401
|
<el-input
|
|
@@ -447,6 +436,23 @@ function patchSelector(patch: Partial<AppiumSelector>) {
|
|
|
447
436
|
/>
|
|
448
437
|
<CoordinatePointPicker :disabled="disabled" @select="applyTapPoint" />
|
|
449
438
|
</section>
|
|
439
|
+
<el-collapse v-if="step.type !== 'aiRecognition'" v-model="editorSections" class="appium-flow-editor__groups appium-flow-editor__groups--meta">
|
|
440
|
+
<el-collapse-item name="meta">
|
|
441
|
+
<template #title>
|
|
442
|
+
<span class="appium-flow-editor__group-title"><strong>节点信息与超时</strong><small>{{ step.label }}</small></span>
|
|
443
|
+
</template>
|
|
444
|
+
<el-form-item label="节点名称">
|
|
445
|
+
<el-input :model-value="step.label" :disabled="disabled" @update:model-value="patchStep({ label: String($event) })" />
|
|
446
|
+
</el-form-item>
|
|
447
|
+
<el-form-item label="备注">
|
|
448
|
+
<el-input :model-value="step.note || ''" :disabled="disabled" maxlength="100" placeholder="例如:登录按钮、账号输入框" @update:model-value="patchStep({ note: String($event) || undefined })" />
|
|
449
|
+
</el-form-item>
|
|
450
|
+
<el-form-item v-if="supportsTimeout" label="超时时间 ms">
|
|
451
|
+
<el-input-number :model-value="step.timeoutMs ?? (step.type === 'delay' ? 1000 : DEFAULT_NODE_TIMEOUT_MS)" :disabled="disabled" :min="0" :max="999999" :step="1000" controls-position="right" @update:model-value="patchTimeout($event)" />
|
|
452
|
+
</el-form-item>
|
|
453
|
+
<BranchTimeoutSettings v-if="defaultKind() === 'condition' && supportsTimeout" :step="step" :disabled="disabled" @update="patchStep({ timeoutBranch: $event })" />
|
|
454
|
+
</el-collapse-item>
|
|
455
|
+
</el-collapse>
|
|
450
456
|
</el-form>
|
|
451
457
|
</div>
|
|
452
458
|
</template>
|
|
@@ -460,6 +466,8 @@ function patchSelector(patch: Partial<AppiumSelector>) {
|
|
|
460
466
|
border-top: 1px solid var(--el-border-color-lighter);
|
|
461
467
|
}
|
|
462
468
|
|
|
469
|
+
.appium-flow-editor :deep(.el-form-item) { margin-bottom: 10px; }
|
|
470
|
+
|
|
463
471
|
.appium-flow-editor__fallback :deep(.el-form-item) {
|
|
464
472
|
margin-bottom: 0;
|
|
465
473
|
}
|
|
@@ -472,4 +480,25 @@ function patchSelector(patch: Partial<AppiumSelector>) {
|
|
|
472
480
|
font-size: 13px;
|
|
473
481
|
line-height: 20px;
|
|
474
482
|
}
|
|
483
|
+
|
|
484
|
+
.appium-flow-editor__groups {
|
|
485
|
+
overflow: hidden;
|
|
486
|
+
margin-top: 8px;
|
|
487
|
+
border: 1px solid var(--el-border-color-lighter);
|
|
488
|
+
border-radius: 10px;
|
|
489
|
+
background: #fff;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
.appium-flow-editor__groups :deep(.el-collapse-item__header) {
|
|
493
|
+
height: 42px;
|
|
494
|
+
padding: 0 10px;
|
|
495
|
+
border-bottom: 0;
|
|
496
|
+
font-size: 12px;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
.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
|
+
.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
|
+
.appium-flow-editor__group-title strong { flex: none; color: var(--ui-text); font-size: 12px; }
|
|
503
|
+
.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; }
|
|
475
504
|
</style>
|
|
@@ -13,16 +13,18 @@ function selector(patch: Partial<AppiumSelector>) {
|
|
|
13
13
|
</script>
|
|
14
14
|
|
|
15
15
|
<template>
|
|
16
|
-
<
|
|
17
|
-
<el-
|
|
18
|
-
<el-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
<el-
|
|
25
|
-
|
|
16
|
+
<div class="appium-flow-editor__grid">
|
|
17
|
+
<el-form-item label="循环方式">
|
|
18
|
+
<el-select :model-value="step.loop?.exitWhen || 'never'" :disabled="disabled" @update:model-value="patch({ exitWhen: $event })">
|
|
19
|
+
<el-option value="never" label="固定次数" />
|
|
20
|
+
<el-option value="exists" label="元素出现时退出" />
|
|
21
|
+
<el-option value="notExists" label="元素消失时退出" />
|
|
22
|
+
</el-select>
|
|
23
|
+
</el-form-item>
|
|
24
|
+
<el-form-item :label="step.loop?.exitWhen === 'never' ? '执行次数' : '最大执行次数'" required>
|
|
25
|
+
<el-input-number :model-value="step.loop?.maxIterations" :disabled="disabled" :min="1" :max="MAX_LOOP_ITERATIONS" :precision="0" controls-position="right" @update:model-value="patch({ maxIterations: Number($event) })" />
|
|
26
|
+
</el-form-item>
|
|
27
|
+
</div>
|
|
26
28
|
<template v-if="step.loop?.exitWhen && step.loop.exitWhen !== 'never'">
|
|
27
29
|
<el-form-item label="退出条件定位方式">
|
|
28
30
|
<el-select :model-value="step.selector?.strategy || 'id'" :disabled="disabled" @update:model-value="selector({ strategy: $event })">
|
|
@@ -298,7 +298,11 @@ function branchSplitPath() {
|
|
|
298
298
|
>
|
|
299
299
|
<span class="appium-flow-node__body">
|
|
300
300
|
<span class="appium-flow-node__title"><span class="appium-flow-node-number">{{ item.index + 1 }}.</span> {{ item.step.label }}</span>
|
|
301
|
-
<span
|
|
301
|
+
<span
|
|
302
|
+
class="appium-flow-node__meta"
|
|
303
|
+
:class="{ 'appium-flow-node__meta--clamped': item.step.type === 'aiRecognition' }"
|
|
304
|
+
:title="item.step.type === 'aiRecognition' ? stepMeta(item.step) : undefined"
|
|
305
|
+
>
|
|
302
306
|
{{ kindLabel(defaultKind(item.step)) }} · {{ typeLabel(item.step) }}
|
|
303
307
|
<template v-if="stepMeta(item.step)"> · {{ stepMeta(item.step) }}</template>
|
|
304
308
|
</span>
|
|
@@ -247,6 +247,12 @@ function resetMainFlowPosition() {
|
|
|
247
247
|
mainResetViewToken.value += 1;
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
defineExpose({ resetMainFlowPosition });
|
|
251
|
+
|
|
252
|
+
function resetDialogFlowPosition() {
|
|
253
|
+
dialogResetViewToken.value += 1;
|
|
254
|
+
}
|
|
255
|
+
|
|
250
256
|
watch(flowDialogVisible, (visible) => {
|
|
251
257
|
if (!visible) return;
|
|
252
258
|
void nextTick(() => {
|
|
@@ -396,6 +402,14 @@ function updateStep(index: number, step: AppiumRecordedStep) {
|
|
|
396
402
|
<el-tooltip v-if="!copyMode" content="批量删除" placement="top" :show-after="200"><span class="flow-toolbar-icon">
|
|
397
403
|
<el-button aria-label="批量删除" size="small" :icon="Delete" :disabled="!steps.length || mergeDisabled || removeDisabled" @click="startDeleteMode" />
|
|
398
404
|
</span></el-tooltip>
|
|
405
|
+
<el-tooltip content="还原位置" placement="top" :show-after="200"><span class="flow-toolbar-icon">
|
|
406
|
+
<el-button
|
|
407
|
+
aria-label="还原位置"
|
|
408
|
+
size="small"
|
|
409
|
+
:icon="Aim"
|
|
410
|
+
@click="resetDialogFlowPosition"
|
|
411
|
+
/>
|
|
412
|
+
</span></el-tooltip>
|
|
399
413
|
</div>
|
|
400
414
|
<FlowCanvas
|
|
401
415
|
id="appium-flow-dialog"
|
|
@@ -5,15 +5,15 @@ const emit = defineEmits<{ update: [patch: Partial<AppiumRecordedStep>] }>();
|
|
|
5
5
|
</script>
|
|
6
6
|
|
|
7
7
|
<template>
|
|
8
|
-
<
|
|
9
|
-
<el-
|
|
10
|
-
@update:model-value="emit('update', { value: String($event) })" />
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
</el-
|
|
18
|
-
</
|
|
8
|
+
<div class="appium-flow-editor__grid">
|
|
9
|
+
<el-form-item label="点击文字" required>
|
|
10
|
+
<el-input :model-value="step.value || ''" :disabled="disabled" maxlength="1000" aria-label="点击文字" @update:model-value="emit('update', { value: String($event) })" />
|
|
11
|
+
</el-form-item>
|
|
12
|
+
<el-form-item label="文本匹配方式">
|
|
13
|
+
<el-select :model-value="step.flow?.textMatch || 'contains'" :disabled="disabled" @update:model-value="emit('update', { flow: { ...props.step.flow, textMatch: $event } })">
|
|
14
|
+
<el-option label="精准匹配(完全一致)" value="exact" />
|
|
15
|
+
<el-option label="模糊匹配(包含)" value="contains" />
|
|
16
|
+
</el-select>
|
|
17
|
+
</el-form-item>
|
|
18
|
+
</div>
|
|
19
19
|
</template>
|
|
@@ -9,9 +9,11 @@ function update(patch: Partial<VariableExtraction>) {
|
|
|
9
9
|
</script>
|
|
10
10
|
|
|
11
11
|
<template>
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
<el-
|
|
15
|
-
|
|
12
|
+
<div class="appium-flow-editor__grid">
|
|
13
|
+
<el-form-item label="保存到脚本变量"><el-input :model-value="step.extractVariable?.name || ''" :disabled="disabled" aria-label="提取变量名" @update:model-value="update({ name: String($event) })" /></el-form-item>
|
|
14
|
+
<el-form-item label="组件属性"><el-select :model-value="step.extractVariable?.attribute || 'text'" :disabled="disabled" filterable allow-create default-first-option aria-label="提取组件属性" @update:model-value="update({ attribute: String($event) })">
|
|
15
|
+
<el-option v-for="name in ['text', 'content-desc', 'checked', 'selected', 'enabled', 'resource-id', 'class']" :key="name" :label="name" :value="name" />
|
|
16
|
+
</el-select></el-form-item>
|
|
17
|
+
</div>
|
|
16
18
|
<el-form-item label="敏感变量"><el-checkbox :model-value="step.extractVariable?.sensitive || sensitiveVariableName(step.extractVariable?.name || '')" :disabled="disabled || sensitiveVariableName(step.extractVariable?.name || '')" @update:model-value="update({ sensitive: Boolean($event) })" /></el-form-item>
|
|
17
19
|
</template>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { InjectionKey, Ref } from 'vue';
|
|
2
2
|
|
|
3
|
-
export const DEFAULT_FLOW_BACKGROUND = '#
|
|
4
|
-
export const FLOW_BACKGROUND_PRESETS = [
|
|
3
|
+
export const DEFAULT_FLOW_BACKGROUND = '#f1f5f9';
|
|
4
|
+
export const FLOW_BACKGROUND_PRESETS = [DEFAULT_FLOW_BACKGROUND, '#d4e8dd', '#d5e6f5', '#e4dcf2', '#f2dedc', '#d5eae9', '#e8e4cc'];
|
|
5
5
|
export const flowBackgroundKey: InjectionKey<Readonly<Ref<string>>> = Symbol('flowBackground');
|
|
6
6
|
export const DEFAULT_FLOW_LINE_COLOR = '#94a3b8';
|
|
7
7
|
export const FLOW_LINE_COLOR_PRESETS = ['#94a3b8', '#719985', '#4b83c4', '#8b6bb1', '#c78a46', '#7b8794', '#374151'];
|
|
@@ -24,3 +24,10 @@ function normalizeFlowColor(value: unknown, fallback: string) {
|
|
|
24
24
|
const color = value.trim().toLowerCase();
|
|
25
25
|
return color.length === 4 ? '#' + [...color.slice(1)].map((char) => char + char).join('') : color;
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
export type FlowLineStyle = 'straight' | 'curved';
|
|
29
|
+
export const flowLineStyleKey: InjectionKey<Readonly<Ref<FlowLineStyle>>> = Symbol('flowLineStyle');
|
|
30
|
+
|
|
31
|
+
export function normalizeFlowLineStyle(value: unknown): FlowLineStyle {
|
|
32
|
+
return value === 'straight' ? 'straight' : 'curved';
|
|
33
|
+
}
|
|
@@ -277,9 +277,12 @@ function estimateTextLines(text: string | undefined, charsPerLine: number) {
|
|
|
277
277
|
), 0);
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
-
function estimateStepNodeHeight(label: { title: string; meta: string; note?: string }) {
|
|
280
|
+
function estimateStepNodeHeight(label: { title: string; meta: string; note?: string }, maxMetaLines?: number) {
|
|
281
281
|
const titleLines = estimateTextLines(label.title, 20);
|
|
282
|
-
const
|
|
282
|
+
const estimatedMetaLines = estimateTextLines(label.meta, 24);
|
|
283
|
+
const metaLines = maxMetaLines == null
|
|
284
|
+
? estimatedMetaLines
|
|
285
|
+
: Math.min(estimatedMetaLines, maxMetaLines);
|
|
283
286
|
const noteLines = estimateTextLines(label.note, 24);
|
|
284
287
|
const textHeight = titleLines * 19 + metaLines * 17 + noteLines * 17;
|
|
285
288
|
return Math.max(FLOW_STEP_NODE_HEIGHT, 34 + textHeight);
|
|
@@ -424,7 +427,10 @@ export function buildFlowGraph(
|
|
|
424
427
|
const label = options.labelStep(item.step);
|
|
425
428
|
// 字数估算仅用于首次布局,不强制卡片高度;实际换行由浏览器决定。
|
|
426
429
|
const cardMinHeight = FLOW_STEP_NODE_HEIGHT;
|
|
427
|
-
const estimatedCardHeight = estimateStepNodeHeight(
|
|
430
|
+
const estimatedCardHeight = estimateStepNodeHeight(
|
|
431
|
+
label,
|
|
432
|
+
item.step.type === 'aiRecognition' ? 3 : undefined,
|
|
433
|
+
);
|
|
428
434
|
const estimatedNodeHeight = options.expandedStepIndex === item.index
|
|
429
435
|
? estimatedCardHeight + FLOW_EXPANDED_NODE_HEIGHT
|
|
430
436
|
: estimatedCardHeight;
|
|
@@ -783,10 +789,10 @@ export function buildFlowGraph(
|
|
|
783
789
|
const joinOwner = joins.get(target.id);
|
|
784
790
|
if (joinOwner && target.id !== joinOwner) {
|
|
785
791
|
const incoming = links.filter((edge) => edge.target === target.id).map((edge) => nodeById.get(edge.source)!).filter(Boolean);
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
setCenterX(target,
|
|
792
|
+
if (incoming.length) {
|
|
793
|
+
target.position.y = Math.round(Math.max(...incoming.map((node) => node.position.y + nodeHeight(node))) + FLOW_STANDARD_LINE_GAP * 4);
|
|
794
|
+
const incomingCenters = incoming.map(centerX);
|
|
795
|
+
setCenterX(target, (Math.min(...incomingCenters) + Math.max(...incomingCenters)) / 2);
|
|
790
796
|
}
|
|
791
797
|
return;
|
|
792
798
|
}
|
|
@@ -68,8 +68,8 @@ 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
|
|
72
|
-
<FlowAppearanceSettings v-model="configForm.appium.flowBackgroundColor" v-model:line-color="configForm.appium.flowLineColor" />
|
|
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" />
|
|
73
73
|
</section>
|
|
74
74
|
</div>
|
|
75
75
|
</template>
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
import { computed } from 'vue';
|
|
3
3
|
import { RefreshLeft } from '@element-plus/icons-vue';
|
|
4
4
|
import {
|
|
5
|
-
DEFAULT_FLOW_BACKGROUND, FLOW_BACKGROUND_PRESETS, normalizeFlowBackground,
|
|
5
|
+
DEFAULT_FLOW_BACKGROUND, FLOW_BACKGROUND_PRESETS, normalizeFlowBackground, normalizeFlowLineStyle, type FlowLineStyle,
|
|
6
6
|
DEFAULT_FLOW_LINE_COLOR, FLOW_LINE_COLOR_PRESETS, normalizeFlowLineColor, isHexColor,
|
|
7
7
|
} from '../../appium-recorder/flow-appearance';
|
|
8
8
|
|
|
9
|
-
const props = defineProps<{ modelValue?: string; lineColor?: string }>();
|
|
10
|
-
const emit = defineEmits<{ 'update:modelValue': [color: string]; 'update:lineColor': [color: string] }>();
|
|
9
|
+
const props = defineProps<{ modelValue?: string; lineColor?: string; lineStyle?: FlowLineStyle }>();
|
|
10
|
+
const emit = defineEmits<{ 'update:modelValue': [color: string]; 'update:lineColor': [color: string]; 'update:lineStyle': [style: FlowLineStyle] }>();
|
|
11
11
|
const panels = computed(() => [
|
|
12
|
-
{ key: 'background' as const, title: '
|
|
12
|
+
{ key: 'background' as const, title: '画布背景色', color: props.modelValue ?? DEFAULT_FLOW_BACKGROUND,
|
|
13
13
|
fallback: DEFAULT_FLOW_BACKGROUND, presets: FLOW_BACKGROUND_PRESETS, normalize: normalizeFlowBackground,
|
|
14
|
-
inputLabel: '十六进制背景色', pickerLabel: '
|
|
14
|
+
inputLabel: '十六进制背景色', pickerLabel: '选择画布背景色', resetLabel: '恢复默认颜色', presetLabel: '选择颜色' },
|
|
15
15
|
{ key: 'line' as const, title: '连接线条颜色', color: props.lineColor ?? DEFAULT_FLOW_LINE_COLOR,
|
|
16
16
|
fallback: DEFAULT_FLOW_LINE_COLOR, presets: FLOW_LINE_COLOR_PRESETS, normalize: normalizeFlowLineColor,
|
|
17
17
|
inputLabel: '十六进制线条颜色', pickerLabel: '选择连接线条颜色', resetLabel: '恢复默认线条颜色', presetLabel: '选择线条颜色' },
|
|
@@ -29,6 +29,13 @@ function update(key: 'background' | 'line', color: string) {
|
|
|
29
29
|
<section v-for="panel in panels" :key="panel.key" class="flow-appearance-section" :aria-label="panel.title">
|
|
30
30
|
<h3>{{ panel.title }}</h3>
|
|
31
31
|
<el-form label-position="top">
|
|
32
|
+
<el-form-item v-if="panel.key === 'line'" label="连接线条样式">
|
|
33
|
+
<el-radio-group :model-value="normalizeFlowLineStyle(lineStyle)" aria-label="连接线条样式"
|
|
34
|
+
@update:model-value="emit('update:lineStyle', normalizeFlowLineStyle($event))">
|
|
35
|
+
<el-radio-button value="straight">直线</el-radio-button>
|
|
36
|
+
<el-radio-button value="curved">曲线</el-radio-button>
|
|
37
|
+
</el-radio-group>
|
|
38
|
+
</el-form-item>
|
|
32
39
|
<el-form-item label="预选颜色">
|
|
33
40
|
<div class="flow-color-presets">
|
|
34
41
|
<button v-for="preset in panel.presets" :key="preset" type="button"
|
|
@@ -4,7 +4,7 @@ import { resolveReportSummary } from '../appium-recorder/report-summary';
|
|
|
4
4
|
import { isAiRecognitionModelConfigured } from '../appium-recorder/ai-recognition';
|
|
5
5
|
import { resolveAiDeduplication } from '../appium-recorder/ai-deduplication';
|
|
6
6
|
import { resolveAiPromptPresets } from '../appium-recorder/ai-prompt-presets';
|
|
7
|
-
import { normalizeFlowBackground, normalizeFlowLineColor } from '../appium-recorder/flow-appearance';
|
|
7
|
+
import { normalizeFlowBackground, normalizeFlowLineColor, normalizeFlowLineStyle } from '../appium-recorder/flow-appearance';
|
|
8
8
|
import { selectMidsceneModelProvider, type MidsceneModelProvider } from './midscene-model-presets';
|
|
9
9
|
import { useAppiumAutoSave } from './use-appium-auto-save';
|
|
10
10
|
import type { ConfigForm } from '../types';
|
|
@@ -76,6 +76,7 @@ export function useModelConfig() {
|
|
|
76
76
|
configForm.appium.aiPromptPresets = resolveAiPromptPresets(payload.appium?.aiPromptPresets);
|
|
77
77
|
configForm.appium.flowBackgroundColor = normalizeFlowBackground(payload.appium?.flowBackgroundColor);
|
|
78
78
|
configForm.appium.flowLineColor = normalizeFlowLineColor(payload.appium?.flowLineColor);
|
|
79
|
+
configForm.appium.flowLineStyle = normalizeFlowLineStyle(payload.appium?.flowLineStyle);
|
|
79
80
|
appiumAutoSave.initialize();
|
|
80
81
|
ready.value = true;
|
|
81
82
|
aiRecognitionModelConfigured.value = isAiRecognitionModelConfigured(configForm.appium.model);
|
package/src/pages/ConfigPage.vue
CHANGED
|
@@ -131,17 +131,17 @@ function handleTabKeydown(event: KeyboardEvent, index: number) {
|
|
|
131
131
|
width: fit-content;
|
|
132
132
|
max-width: calc(100% - 48px);
|
|
133
133
|
flex-wrap: wrap;
|
|
134
|
-
gap:
|
|
134
|
+
gap: 2px;
|
|
135
135
|
margin: 20px 24px 0;
|
|
136
136
|
padding: 4px;
|
|
137
137
|
border: 1px solid var(--ui-border);
|
|
138
|
-
border-radius:
|
|
138
|
+
border-radius: var(--ui-radius-pill);
|
|
139
139
|
background: var(--ui-bg-soft);
|
|
140
|
-
box-shadow: var(--ui-shadow-
|
|
140
|
+
box-shadow: var(--ui-shadow-inset);
|
|
141
141
|
}
|
|
142
142
|
.config-tabs .subnav__item {
|
|
143
|
-
min-height:
|
|
144
|
-
padding: 6px
|
|
143
|
+
min-height: 32px;
|
|
144
|
+
padding: 6px 14px;
|
|
145
145
|
border: 0;
|
|
146
146
|
border-radius: var(--ui-radius-pill);
|
|
147
147
|
font-size: 13px;
|
|
@@ -149,7 +149,7 @@ function handleTabKeydown(event: KeyboardEvent, index: number) {
|
|
|
149
149
|
.config-tabs .subnav__item--active {
|
|
150
150
|
background: var(--ui-surface);
|
|
151
151
|
color: var(--ui-primary);
|
|
152
|
-
box-shadow: var(--ui-shadow-
|
|
152
|
+
box-shadow: var(--ui-shadow-control);
|
|
153
153
|
}
|
|
154
154
|
.config-page > [role="tabpanel"] { padding: 24px; }
|
|
155
155
|
:deep(.config-module-card > .el-card__header) { padding: 18px 24px; font-size: 16px; font-weight: 600; }
|