android-midscene-automation 1.1.8 → 1.1.10

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.
@@ -0,0 +1,139 @@
1
+ <script setup lang="ts">
2
+ import { computed, inject, onMounted, shallowRef, useTemplateRef } from 'vue';
3
+ import { ElMessage } from 'element-plus';
4
+ import { Upload } from '@element-plus/icons-vue';
5
+ import type { AppiumRecordedStep } from '../types';
6
+ import { defaultRandomValue, MAX_RANDOM_FILE_BYTES, randomTextCandidates, type RandomValueConfig } from '../random-value';
7
+ import { sensitiveVariableName } from '../variables';
8
+ import { variablePresetKey, type VariablePresetContext } from '../variable-presets';
9
+
10
+ const props = defineProps<{ step: AppiumRecordedStep; disabled?: boolean; presets?: VariablePresetContext }>();
11
+ const emit = defineEmits<{ update: [Partial<AppiumRecordedStep>] }>();
12
+ const config = computed(() => ({ ...defaultRandomValue(), ...props.step.randomValue }));
13
+ const fileInput = useTemplateRef<HTMLInputElement>('fileInput');
14
+ const importing = shallowRef(false);
15
+ const inheritedPresets = inject(variablePresetKey, undefined);
16
+ const presets = computed(() => props.presets || inheritedPresets);
17
+ const variableOptions = computed(() => presets.value?.options.value || []);
18
+ const variablesLoading = computed(() => presets.value?.loading.value || false);
19
+ const variablesError = computed(() => presets.value?.error.value || '');
20
+ const selectedVariable = computed(() => variableOptions.value.find(variable => variable.name === config.value.name));
21
+ const fixedSensitive = computed(() => Boolean(selectedVariable.value?.sensitive || sensitiveVariableName(config.value.name)));
22
+ const sensitive = computed(() => Boolean(config.value.sensitive || fixedSensitive.value));
23
+ const missingVariable = computed(() => Boolean(config.value.name && !selectedVariable.value && !variablesLoading.value));
24
+ const reference = computed(() => `{{${config.value.name || '变量名'}}}`);
25
+ const candidateCount = computed(() => {
26
+ try {
27
+ const candidates = randomTextCandidates(config.value.text);
28
+ return config.value.withoutReplacement ? new Set(candidates).size : candidates.length;
29
+ } catch { return 0; }
30
+ });
31
+
32
+ function update(patch: Partial<RandomValueConfig>) {
33
+ emit('update', { randomValue: { ...config.value, ...patch } });
34
+ }
35
+
36
+ function refreshVariables(visible: boolean) {
37
+ if (visible) void presets.value?.refresh();
38
+ }
39
+
40
+ onMounted(() => { void presets.value?.refresh(); });
41
+
42
+ async function importText(event: Event) {
43
+ const input = event.target as HTMLInputElement;
44
+ const file = input.files?.[0];
45
+ input.value = '';
46
+ if (!file || props.disabled) return;
47
+ importing.value = true;
48
+ try {
49
+ if (file.size > MAX_RANDOM_FILE_BYTES) throw new Error('TXT 文件不能超过 1 MB');
50
+ const text = new TextDecoder('utf-8', { fatal: true }).decode(await file.arrayBuffer());
51
+ randomTextCandidates(text);
52
+ update({ text, sourceName: file.name });
53
+ } catch (error) {
54
+ ElMessage.error(error instanceof TypeError ? '请导入 UTF-8 编码的 TXT 文件' : error instanceof Error ? error.message : 'TXT 导入失败');
55
+ } finally { importing.value = false; }
56
+ }
57
+
58
+ </script>
59
+
60
+ <template>
61
+ <div class="random-value-settings">
62
+ <el-form-item label="结果类型">
63
+ <el-select :model-value="config.mode" :disabled="disabled" aria-label="随机值类型" @update:model-value="update({ mode: $event })">
64
+ <el-option label="预设文本 / TXT" value="text" />
65
+ <el-option label="随机整数" value="integer" />
66
+ <el-option label="随机 ID(UUID)" value="uuid" />
67
+ </el-select>
68
+ </el-form-item>
69
+ <el-form-item label="保存到变量">
70
+ <div class="random-value-settings__field">
71
+ <el-select class="random-value-settings__variable-select" :model-value="config.name || undefined" :disabled="disabled" :loading="variablesLoading" filterable placeholder="选择预设变量 key" aria-label="随机值变量名" @visible-change="refreshVariables" @update:model-value="update({ name: String($event), sensitive: variableOptions.find(variable => variable.name === $event)?.sensitive || undefined })">
72
+ <el-option v-if="missingVariable" :label="`${config.name}(未预设)`" :value="config.name" disabled />
73
+ <el-option v-for="variable in variableOptions" :key="variable.name" :label="variable.name" :value="variable.name">
74
+ <span>{{ variable.name }}</span><small class="random-value-settings__scope">{{ variable.scope === 'private' ? '私有' : '全局' }}</small>
75
+ </el-option>
76
+ <template #empty><div class="random-value-settings__empty">暂无匹配的预设变量</div></template>
77
+ </el-select>
78
+ <div class="random-value-settings__variable-help">
79
+ <span class="random-value-settings__hint">{{ selectedVariable ? (selectedVariable.scope === 'private' ? '当前脚本私有变量' : '使用全局 key,结果保存在当前脚本') : '选择已有 key 保存结果' }}</span>
80
+ <el-button link type="primary" :disabled="disabled || !presets" @click="presets?.open()">去添加变量</el-button>
81
+ </div>
82
+ <span v-if="variablesError" class="random-value-settings__error" role="alert">变量加载失败 <el-button link type="primary" :disabled="variablesLoading" @click="presets?.refresh()">重试</el-button></span>
83
+ <span v-else-if="missingVariable" class="random-value-settings__error" role="alert">此 key 尚未预设,请先添加或重新选择。</span>
84
+ </div>
85
+ </el-form-item>
86
+ <template v-if="config.mode === 'text'">
87
+ <el-form-item label="候选内容">
88
+ <div class="random-value-settings__field">
89
+ <el-input type="textarea" :rows="4" :model-value="config.text || ''" :disabled="disabled" placeholder="每行一条候选内容" aria-label="随机候选内容" @update:model-value="update({ text: String($event), sourceName: undefined })" />
90
+ <div class="random-value-settings__import">
91
+ <input ref="fileInput" type="file" accept=".txt,text/plain" hidden aria-label="导入随机候选 TXT" :disabled="disabled || importing" @change="importText" />
92
+ <el-button :icon="Upload" :disabled="disabled" :loading="importing" @click="fileInput?.click()">导入 TXT</el-button>
93
+ <span class="random-value-settings__count">{{ candidateCount }} 条{{ config.withoutReplacement ? '不同' : '' }}候选</span>
94
+ </div>
95
+ <span v-if="config.sourceName" class="random-value-settings__hint random-value-settings__file" :title="config.sourceName">{{ config.sourceName }}</span>
96
+ <span class="random-value-settings__hint">UTF-8 · 每行一条,忽略空行和 # 注释。内容随脚本保存。</span>
97
+ </div>
98
+ </el-form-item>
99
+ <el-form-item label="抽取方式">
100
+ <div class="random-value-settings__field">
101
+ <el-select :model-value="config.withoutReplacement === true" :disabled="disabled" aria-label="随机抽取方式" @update:model-value="update({ withoutReplacement: $event === true })">
102
+ <el-option label="允许重复抽取" :value="false" />
103
+ <el-option label="本次运行不重复" :value="true" />
104
+ </el-select>
105
+ <span v-if="config.withoutReplacement" class="random-value-settings__hint">候选耗尽时停止,下次回放重新开始。</span>
106
+ </div>
107
+ </el-form-item>
108
+ </template>
109
+ <template v-if="config.mode === 'integer'">
110
+ <el-form-item label="最小值">
111
+ <el-input-number :model-value="config.min ?? 0" :disabled="disabled" :precision="0" controls-position="right" aria-label="随机整数最小值" @update:model-value="update({ min: $event ?? 0 })" />
112
+ </el-form-item>
113
+ <el-form-item label="最大值">
114
+ <el-input-number :model-value="config.max ?? 9999" :disabled="disabled" :precision="0" controls-position="right" aria-label="随机整数最大值" @update:model-value="update({ max: $event ?? 9999 })" />
115
+ </el-form-item>
116
+ <span class="random-value-settings__hint">包含最小值和最大值,结果以文本保存。</span>
117
+ </template>
118
+ <span v-if="config.mode === 'uuid'" class="random-value-settings__hint">每次执行生成一个 UUID,并以文本保存。</span>
119
+ <el-form-item label="敏感值">
120
+ <el-checkbox :model-value="sensitive" :disabled="disabled || fixedSensitive" @update:model-value="update({ sensitive: $event === true })">隐藏日志中的结果</el-checkbox>
121
+ </el-form-item>
122
+ <span v-if="sensitive && config.mode === 'text'" class="random-value-settings__hint">导出时清空敏感候选内容。</span>
123
+ <span class="random-value-settings__hint">后续通过 <code>{{ reference }}</code> 引用结果。</span>
124
+ </div>
125
+ </template>
126
+
127
+ <style scoped>
128
+ .random-value-settings { display: flex; flex-direction: column; gap: 12px; min-width: 0; text-align: left; }
129
+ .random-value-settings :deep(.el-form-item) { margin-bottom: 0; }
130
+ .random-value-settings__field { display: grid; gap: 8px; width: 100%; min-width: 0; }
131
+ .random-value-settings__import, .random-value-settings__variable-help { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
132
+ .random-value-settings__variable-help .el-button { padding: 0; font-size: 12px; }
133
+ .random-value-settings__count { font-size: 12px; color: var(--ui-text-secondary, #64748b); }
134
+ .random-value-settings__scope { float: right; margin-left: 16px; color: var(--el-text-color-secondary); }
135
+ .random-value-settings__empty { padding: 12px; color: var(--el-text-color-secondary); text-align: center; }
136
+ .random-value-settings__file { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
137
+ .random-value-settings__error { color: var(--el-color-danger); font-size: 12px; line-height: 1.5; }
138
+ .random-value-settings__hint { color: var(--ui-text-secondary, #64748b); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
139
+ </style>
@@ -115,6 +115,7 @@ const insertActionGroups: FlowActionGroup[] = [
115
115
  {
116
116
  title: '流程控制',
117
117
  actions: [
118
+ { type: 'randomValue', label: '获取随机值' },
118
119
  { type: 'noop', label: '空节点' },
119
120
  { type: 'endFlow', label: '终止流程' },
120
121
  {
@@ -50,6 +50,7 @@ export type InsertAction =
50
50
  | 'waitActivity'
51
51
  | 'runScript'
52
52
  | 'extractVariable'
53
+ | 'randomValue'
53
54
  | 'noop'
54
55
  | 'log'
55
56
  | 'visualChangeStart'
@@ -835,8 +836,8 @@ export function buildFlowGraph(
835
836
  source: link.source,
836
837
  target: link.target,
837
838
  type: 'flow-rounded',
838
- sourceHandle: 'bottom',
839
- targetHandle: 'top',
839
+ sourceHandle: 'output',
840
+ targetHandle: 'input',
840
841
  selectable: false,
841
842
  focusable: false,
842
843
  class: 'appium-vue-flow-edge',
@@ -6,6 +6,7 @@ import { isNativeStateCondition } from './native-control-state';
6
6
  import { DEFAULT_LOG_PREFIX } from './stage-log';
7
7
  import { imageCheckSummary } from './image-check';
8
8
  import { isAiBranchEnabled } from './ai-recognition';
9
+ import { randomValueSummary } from './random-value';
9
10
 
10
11
  export function isBooleanCondition(step: Pick<AppiumRecordedStep, 'type' | 'aiBranchEnabled'>) {
11
12
  return isNativeStateCondition(step) || (step.type === 'aiRecognition' && isAiBranchEnabled(step)) || step.type === 'textClick' || step.type === 'imageCheck';
@@ -13,7 +14,7 @@ export function isBooleanCondition(step: Pick<AppiumRecordedStep, 'type' | 'aiBr
13
14
 
14
15
  export function defaultFlowKind(step: AppiumRecordedStep): FlowKind {
15
16
  if (step.type === 'aiRecognition') return isAiBranchEnabled(step) ? 'condition' : 'action';
16
- if (step.type === 'extractVariable') return 'action';
17
+ if (step.type === 'extractVariable' || step.type === 'randomValue') return 'action';
17
18
  if (step.type === 'loop') return 'condition';
18
19
  if (step.type === 'breakLoop' || step.type === 'continueLoop') return 'action';
19
20
  if (step.type === 'log' || step.type === 'openGallery' || step.type === 'endFlow') return 'action';
@@ -73,12 +74,14 @@ export function flowTypeLabel(step: AppiumRecordedStep) {
73
74
  noop: '空节点',
74
75
  log: '输出日志',
75
76
  extractVariable: '提取变量',
77
+ randomValue: '获取随机值',
76
78
  visualChange: '检测画面变化',
77
79
  };
78
80
  return labelMap[step.type] || step.type;
79
81
  }
80
82
 
81
83
  export function flowStepMeta(step: AppiumRecordedStep) {
84
+ if (step.type === 'randomValue') return randomValueSummary(step.randomValue);
82
85
  if (step.type === 'imageCheck') return imageCheckSummary(step.imageCheck);
83
86
  if (step.type === 'extractVariable') return `${step.extractVariable?.attribute || 'text'} → ${step.extractVariable?.name || '未设置变量名'}`;
84
87
  if (step.type === 'loop') return `最多 ${step.loop?.maxIterations ?? '?'} 次 · ${step.loop?.exitWhen === 'exists' ? '元素出现时退出' : step.loop?.exitWhen === 'notExists' ? '元素消失时退出' : '固定次数'}${step.loop?.exitWhen !== 'never' ? ` ${step.selector?.value || ''}` : ''}`;
@@ -0,0 +1,60 @@
1
+ import { sensitiveVariableName, validateVariables } from './variables';
2
+
3
+ export type RandomValueConfig = {
4
+ name: string;
5
+ mode: 'text' | 'integer' | 'uuid';
6
+ text?: string;
7
+ sourceName?: string;
8
+ withoutReplacement?: boolean;
9
+ min?: number;
10
+ max?: number;
11
+ sensitive?: boolean;
12
+ };
13
+
14
+ export const MAX_RANDOM_TEXT_LENGTH = 200000;
15
+ export const MAX_RANDOM_FILE_BYTES = 1024 * 1024;
16
+ export const MAX_RANDOM_INTEGER_RANGE = 2 ** 48 - 1;
17
+ export const defaultRandomValue = (): RandomValueConfig => ({
18
+ name: 'RANDOM_VALUE', mode: 'text', text: '', min: 0, max: 9999, withoutReplacement: false,
19
+ });
20
+
21
+ export function randomTextCandidates(text: unknown): string[] {
22
+ if (typeof text !== 'string' || text.length > MAX_RANDOM_TEXT_LENGTH) throw new Error(`候选文本须为文本且不超过 ${MAX_RANDOM_TEXT_LENGTH} 字符`);
23
+ const candidates = text.replace(/^\uFEFF/, '').split(/\r?\n/u).map(line => line.trim())
24
+ .filter(line => line && !line.startsWith('#'));
25
+ if (!candidates.length) throw new Error('请填写候选文本或导入 TXT,每行一条');
26
+ if (candidates.length > 10000 || candidates.some(line => line.length > 20000)) throw new Error('候选最多 10000 条,每条不超过 20000 字符');
27
+ return candidates;
28
+ }
29
+
30
+ export function validateRandomValue(input: RandomValueConfig | undefined, options: { allowEmptySensitiveText?: boolean } = {}): RandomValueConfig {
31
+ if (!input || typeof input !== 'object') throw new Error('请配置获取随机值节点');
32
+ validateVariables([{ name: input.name, value: '', sensitive: input.sensitive }]);
33
+ if (input.withoutReplacement !== undefined && typeof input.withoutReplacement !== 'boolean') throw new Error('不重复抽取选项须为布尔值');
34
+ if (input.sensitive !== undefined && typeof input.sensitive !== 'boolean') throw new Error('敏感值选项须为布尔值');
35
+ // 敏感池导出时清空;允许导入为待填写模板,实际预览和执行仍须有候选内容。
36
+ if (input.mode === 'text') {
37
+ if (!(options.allowEmptySensitiveText && input.text === '' && (input.sensitive || sensitiveVariableName(input.name)))) randomTextCandidates(input.text);
38
+ }
39
+ else if (input.mode === 'integer') {
40
+ if (!Number.isSafeInteger(input.min) || !Number.isSafeInteger(input.max) || input.min! > input.max!) throw new Error('最小值和最大值须为安全整数,且最小值不能大于最大值');
41
+ const range = input.max! - input.min! + 1;
42
+ if (!Number.isSafeInteger(range) || range > MAX_RANDOM_INTEGER_RANGE) throw new Error(`整数范围跨度不能超过 ${MAX_RANDOM_INTEGER_RANGE}`);
43
+ } else if (input.mode !== 'uuid') throw new Error('随机值类型无效');
44
+ return input;
45
+ }
46
+
47
+ export function randomValueSummary(config: RandomValueConfig | undefined) {
48
+ if (!config) return '未配置随机值';
49
+ let source = '随机 ID(UUID)';
50
+ if (config.mode === 'integer') source = `随机整数 ${config.min ?? '?'}~${config.max ?? '?'}`;
51
+ if (config.mode === 'text') {
52
+ let count = 0;
53
+ try {
54
+ const candidates = randomTextCandidates(config.text);
55
+ count = config.withoutReplacement ? new Set(candidates).size : candidates.length;
56
+ } catch { /* 编辑中的空内容仍允许展示节点。 */ }
57
+ source = `${count} 条候选 · ${config.withoutReplacement ? '本次运行不重复' : '允许重复'}`;
58
+ }
59
+ return `${source} → ${config.name || '未设置变量名'}`;
60
+ }
@@ -1,6 +1,7 @@
1
1
  import type { AiInvalidResultBranch, AiObservationConfig } from './ai-recognition';
2
2
  import type { TestVariable, VariableExtraction, ScriptReturn } from './variables';
3
3
  import type { ImageCheckConfig } from './image-check';
4
+ import type { RandomValueConfig } from './random-value';
4
5
 
5
6
  export type AppiumBounds = {
6
7
  left: number;
@@ -108,6 +109,7 @@ export type AppiumRecordedStep = {
108
109
  | 'runScript'
109
110
  | 'noop'
110
111
  | 'extractVariable'
112
+ | 'randomValue'
111
113
  | 'log'
112
114
  | 'visualChange';
113
115
  label: string;
@@ -119,6 +121,7 @@ export type AppiumRecordedStep = {
119
121
  value?: string;
120
122
  logPrefix?: string;
121
123
  extractVariable?: VariableExtraction;
124
+ randomValue?: RandomValueConfig;
122
125
  parameters?: TestVariable[];
123
126
  returns?: ScriptReturn[];
124
127
  keyCode?: number;
@@ -0,0 +1,24 @@
1
+ import type { InjectionKey, Ref } from 'vue';
2
+ import { sensitiveVariableName, VARIABLE_NAME, type TestVariable } from './variables';
3
+
4
+ export type VariablePresetOption = { name: string; sensitive: boolean; scope: 'global' | 'private' };
5
+ export type VariablePresetContext = {
6
+ options: Readonly<Ref<VariablePresetOption[]>>;
7
+ loading: Readonly<Ref<boolean>>;
8
+ error: Readonly<Ref<string>>;
9
+ refresh: () => Promise<void>;
10
+ open: () => void;
11
+ };
12
+ export const variablePresetKey: InjectionKey<VariablePresetContext> = Symbol('variable-presets');
13
+
14
+ export function variablePresetOptions(globals: TestVariable[], privateVariables: TestVariable[]): VariablePresetOption[] {
15
+ const options = new Map<string, VariablePresetOption>();
16
+ for (const [scope, variables] of [['global', globals], ['private', privateVariables]] as const) {
17
+ for (const variable of variables) {
18
+ if (!VARIABLE_NAME.test(variable.name) || variable.name.length > 80) continue;
19
+ options.set(variable.name, { name: variable.name, scope,
20
+ sensitive: Boolean(variable.sensitive || options.get(variable.name)?.sensitive || sensitiveVariableName(variable.name)) });
21
+ }
22
+ }
23
+ return [...options.values()];
24
+ }
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { computed } from 'vue';
3
+ import { QuestionFilled } from '@element-plus/icons-vue';
3
4
  import { resolveAiDeduplication, type AiDeduplicationConfig } from '../../appium-recorder/ai-deduplication';
4
5
 
5
6
  const props = defineProps<{ modelValue?: AiDeduplicationConfig; disabled?: boolean }>();
@@ -14,6 +15,21 @@ function patch(value: Partial<AiDeduplicationConfig>) {
14
15
  <section class="ai-dedup-settings" aria-label="持续观察截图去重">
15
16
  <p class="ai-dedup-description">相似截图在本地过滤后再提交模型,减少重复图片和识别开销。</p>
16
17
  <el-form-item label="去重方式">
18
+ <template #label>
19
+ <span class="ai-dedup-label">去重方式
20
+ <el-tooltip placement="top" :show-after="200">
21
+ <template #content>
22
+ <div class="ai-dedup-explanation">
23
+ <p><strong>不去重:</strong>全部采样截图交给模型,保留信息最多,图片输入消耗也最高。</p>
24
+ <p><strong>pixelmatch:</strong>比较原图的像素颜色和变化面积,适合同设备的静态画面,对细节变化敏感。</p>
25
+ <p><strong>OpenCV(SSIM):</strong>缩小图片后比较彩色画面的局部亮度、对比度和结构,更侧重整体相似性;可能忽略小文字,不能识别语义,也不自动对齐位移。</p>
26
+ <p>仅对持续观察生效。首帧始终保留,后续与上一张保留的截图比较;两种去重均在本地完成,不调用模型。切换方式会保留各自参数,用于后续回放和识别测试。</p>
27
+ </div>
28
+ </template>
29
+ <el-button class="ai-dedup-help-button" text :icon="QuestionFilled" aria-label="去重方式说明" @click.prevent />
30
+ </el-tooltip>
31
+ </span>
32
+ </template>
17
33
  <el-radio-group :model-value="settings.method" :disabled="disabled" @update:model-value="patch({ method: $event as AiDeduplicationConfig['method'] })">
18
34
  <el-radio-button value="none">不去重</el-radio-button>
19
35
  <el-radio-button value="pixelmatch">pixelmatch(默认)</el-radio-button>
@@ -40,20 +56,15 @@ function patch(value: Partial<AiDeduplicationConfig>) {
40
56
  <p class="ai-dedup-help">默认 512。仅缩小本地比较图像;越大越能保留细节,也更耗本地计算资源,不改变提交模型的图片尺寸。</p>
41
57
  </el-form-item>
42
58
  </template>
43
- <div class="ai-dedup-explanation">
44
- <h4>去重方式说明</h4>
45
- <p><strong>不去重:</strong>全部采样截图交给模型,保留信息最多,图片输入消耗也最高。</p>
46
- <p><strong>pixelmatch:</strong>比较原图的像素颜色和变化面积,适合同设备的静态画面,对细节变化敏感。</p>
47
- <p><strong>OpenCV(SSIM):</strong>缩小图片后比较彩色画面的局部亮度、对比度和结构,更侧重整体相似性;可能忽略小文字,不能识别语义,也不自动对齐位移。</p>
48
- <p>仅对持续观察生效。首帧始终保留,后续与上一张保留的截图比较;两种去重均在本地完成,不调用模型。切换方式会保留各自参数,用于后续回放和识别测试。</p>
49
- </div>
50
59
  </section>
51
60
  </template>
52
61
 
53
62
  <style scoped>
54
63
  .ai-dedup-description { margin: 0 0 18px; color: var(--el-text-color-secondary); font-size: 12px; line-height: 1.6; }
55
64
  .ai-dedup-help { width: 100%; margin: 6px 0 0; color: var(--el-text-color-secondary); font-size: 12px; line-height: 1.6; }
56
- .ai-dedup-explanation { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--ui-border); color: var(--el-text-color-regular); font-size: 13px; line-height: 1.7; }
57
- .ai-dedup-explanation h4 { margin: 0 0 8px; color: var(--el-text-color-primary); font-size: 13px; }
58
- .ai-dedup-explanation p { margin: 6px 0; }
65
+ .ai-dedup-label { display: inline-flex; align-items: center; gap: 4px; }
66
+ .ai-dedup-help-button { width: 28px; height: 28px; padding: 0; font-size: 16px; }
67
+ .ai-dedup-explanation { max-width: min(360px, calc(100vw - 40px)); line-height: 1.6; overflow-wrap: anywhere; }
68
+ .ai-dedup-explanation p { margin: 0 0 8px; }
69
+ .ai-dedup-explanation p:last-child { margin-bottom: 0; }
59
70
  </style>
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { shallowRef } from 'vue';
2
3
  import ReplayReportSummarySettings from './ReplayReportSummarySettings.vue';
3
4
  import type { ConfigForm } from '../../types';
4
5
  import FlowAppearanceSettings from './FlowAppearanceSettings.vue';
@@ -16,15 +17,25 @@ defineProps<{
16
17
  }>();
17
18
  defineEmits<{
18
19
  retrySave: []; testModel: []; testPromptOptimizerModel: [] }>();
20
+
21
+ const activeSection = shallowRef<'basic' | 'models'>('basic');
19
22
  </script>
20
23
 
21
24
  <template>
22
25
  <div class="appium-config-stack">
23
- <section class="appium-config-section" aria-labelledby="appium-models-title">
24
- <header class="appium-section-heading">
25
- <div><h2 id="appium-models-title">模型服务</h2><p>不同任务使用独立模型,配置修改需测试通过后保存。</p></div>
26
+ <header class="appium-config-toolbar">
27
+ <el-radio-group v-model="activeSection" aria-label="Appium配置分类">
28
+ <el-radio-button value="basic">基础配置</el-radio-button>
29
+ <el-radio-button value="models">模型配置</el-radio-button>
30
+ </el-radio-group>
31
+ <div v-if="saveStatus || saveFailed" class="appium-config-save-state">
26
32
  <span v-if="saveStatus" class="config-save-status" role="status">{{ saveStatus }}</span>
27
33
  <el-button v-if="saveFailed" link type="primary" @click="$emit('retrySave')">重试保存</el-button>
34
+ </div>
35
+ </header>
36
+ <section v-show="activeSection === 'models'" class="appium-config-section" aria-labelledby="appium-models-title">
37
+ <header class="appium-section-heading">
38
+ <div><h2 id="appium-models-title">模型服务</h2><p>不同任务使用独立模型,配置修改需测试通过后保存。</p></div>
28
39
  </header>
29
40
  <div class="appium-model-grid">
30
41
  <AppiumModelSettings v-model="configForm.appium.model" title="AI 识别模型" badge="视觉"
@@ -37,8 +48,8 @@ defineEmits<{
37
48
  </div>
38
49
  </section>
39
50
 
40
- <section class="appium-config-section" aria-labelledby="appium-recognition-title">
41
- <header class="appium-section-heading"><div><h2 id="appium-recognition-title">AI 识别设置</h2><p>控制持续观察的截图筛选,并管理录制节点可选的常用提示词。</p></div></header>
51
+ <section v-show="activeSection === 'models'" class="appium-config-section" aria-labelledby="appium-recognition-title">
52
+ <header class="appium-section-heading"><div><h2 id="appium-recognition-title">AI 应用设置</h2><p>配置持续观察的截图筛选、常用提示词,以及回放报告总结。</p></div></header>
42
53
  <div class="appium-settings-grid">
43
54
  <el-card shadow="never" class="config-module-card config-appium-card">
44
55
  <template #header><div class="panel-header"><span>持续观察截图去重</span></div></template>
@@ -49,10 +60,11 @@ defineEmits<{
49
60
  <AiPromptPresetsSettings v-model="configForm.appium.aiPromptPresets" />
50
61
  </el-card>
51
62
  </div>
63
+ <ReplayReportSummarySettings v-if="configForm.appium.reportSummary" :config="configForm.appium.reportSummary" :testing-model-key="testingModelKey" />
52
64
  </section>
53
65
 
54
- <section class="appium-config-section" aria-labelledby="appium-replay-title">
55
- <header class="appium-section-heading"><div><h2 id="appium-replay-title">回放与报告</h2><p>配置回放证据、基础报告和 AI 总结。</p></div></header>
66
+ <section v-show="activeSection === 'basic'" class="appium-config-section" aria-labelledby="appium-replay-title">
67
+ <header class="appium-section-heading"><div><h2 id="appium-replay-title">回放与报告</h2><p>配置节点截图和 HTML 报告。</p></div></header>
56
68
  <el-card shadow="never" class="config-module-card config-appium-card">
57
69
  <template #header>
58
70
  <div class="panel-header">
@@ -64,10 +76,9 @@ defineEmits<{
64
76
  </template>
65
77
  <el-alert title="开启后会在节点执行前后截图并生成 HTML 报告。截图会增加回放耗时,实际操作间隔可能超过设置的延时时间。" type="info" :closable="false" show-icon />
66
78
  </el-card>
67
- <ReplayReportSummarySettings v-if="configForm.appium.reportSummary" :config="configForm.appium.reportSummary" :testing-model-key="testingModelKey" />
68
79
  </section>
69
80
 
70
- <section class="appium-config-section" aria-labelledby="appium-editor-title">
81
+ <section v-show="activeSection === 'basic'" class="appium-config-section" aria-labelledby="appium-editor-title">
71
82
  <header class="appium-section-heading"><div><h2 id="appium-editor-title">流程编辑器</h2><p>选择流程主题,调整画布、节点和连接线颜色,以及横纵布局。</p></div></header>
72
83
  <FlowAppearanceSettings
73
84
  v-model="configForm.appium.flowBackgroundColor"
@@ -85,6 +96,8 @@ defineEmits<{
85
96
  <style scoped>
86
97
  .config-save-status { font-size: 12px; font-weight: 400; color: var(--el-text-color-secondary); }
87
98
  .appium-config-stack { display: grid; gap: 28px; }
99
+ .appium-config-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
100
+ .appium-config-save-state { display: flex; align-items: center; gap: 8px; }
88
101
  .appium-config-section { display: grid; gap: 14px; min-width: 0; }
89
102
  .appium-section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 0 4px; }
90
103
  .appium-section-heading h2 { margin: 0; color: var(--el-text-color-primary); font-size: 16px; line-height: 1.4; }
@@ -31,8 +31,8 @@ defineEmits<{
31
31
 
32
32
  const tabs = [
33
33
  { name: 'basic', label: '基础配置' },
34
- { name: 'midscene', label: 'Midscene配置' },
35
34
  { name: 'appium', label: 'Appium配置' },
35
+ { name: 'midscene', label: 'Midscene配置' },
36
36
  ] as const;
37
37
  const activeTab = shallowRef<(typeof tabs)[number]['name']>('basic');
38
38