android-midscene-automation 1.1.10 → 1.1.11

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 CHANGED
@@ -1,8 +1,10 @@
1
1
  # 更新记录
2
+ ## [1.1.11]
3
+ - [Appium]新增通用“计时打点”操作,支持开始、记录任意阶段和结束;通过系统生成的计时器 ID 关联。
4
+ - [Appium]“获取随机值”节点支持选择已有全局或私有预设变量;缺少变量时可前往添加并返回继续配置,同步保护敏感候选内容。
2
5
 
3
6
  ## [1.1.10]
4
7
  - [Appium]新增“获取随机值”操作节点,支持预设文本及 TXT 抽取、随机整数和 UUID。
5
- - [发布]修复发布脚本无法识别 `## [版本号]` 格式更新记录的问题,保留旧版本标题格式兼容。
6
8
 
7
9
  ## [1.1.9]
8
10
  - [Appium]修复横向流程中展开节点及内部折叠选项时连接点偏移的问题。
package/README.md CHANGED
@@ -1502,9 +1502,12 @@ Linux: ~/.local/share/android-midscene-automation
1502
1502
 
1503
1503
  # 项目更新记录
1504
1504
 
1505
+ ## [1.1.11]
1506
+ - [Appium]新增通用“计时打点”操作,支持开始、记录任意阶段和结束;通过系统生成的计时器 ID 关联。
1507
+ - [Appium]“获取随机值”节点支持选择已有全局或私有预设变量;缺少变量时可前往添加并返回继续配置,同步保护敏感候选内容。
1508
+
1505
1509
  ## [1.1.10]
1506
1510
  - [Appium]新增“获取随机值”操作节点,支持预设文本及 TXT 抽取、随机整数和 UUID。
1507
- - [发布]修复发布脚本无法识别 `## [版本号]` 格式更新记录的问题,保留旧版本标题格式兼容。
1508
1511
 
1509
1512
  ## [1.1.9]
1510
1513
  - [Appium]修复横向流程中展开节点及内部折叠选项时连接点偏移的问题。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "android-midscene-automation",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/oooooooko/android-midscene-automation.git"
@@ -2,6 +2,7 @@ import { resolveReportSummary } from '../../src/appium-recorder/report-summary';
2
2
  import { execFile } from 'node:child_process';
3
3
  import { VariableScope, variableContext, resolveVariableStep } from './variables';
4
4
  import { RandomValueGenerator } from './random-value';
5
+ import { ReplayStopwatches } from './stopwatch';
5
6
  import { getPresetVariables } from './variable-store';
6
7
  import { validateExtraction, validateVariables, type TestVariable } from '../../src/appium-recorder/variables';
7
8
  import { captureHistoryFrames, readAppVersion } from './history-capture';
@@ -73,6 +74,7 @@ type PendingVisualChangeCheck = {
73
74
 
74
75
  const replayContext = new AsyncLocalStorage<{
75
76
  randomValues: RandomValueGenerator;
77
+ stopwatches: ReplayStopwatches;
76
78
  signal?: AbortSignal;
77
79
  appiumLog: (line: string) => void;
78
80
  serverUrl: string;
@@ -927,6 +929,11 @@ async function runStep(
927
929
  ): Promise<RunStepResult | void> {
928
930
  throwIfReplayStopped();
929
931
  step = resolveVariableStep(step);
932
+ if (step.type === 'stopwatch') {
933
+ const context = replayContext.getStore();
934
+ if (!context || !step.stopwatch) throw new Error('计时打点配置未初始化');
935
+ return `TIMER:${JSON.stringify(context.stopwatches.record(step.stopwatch, step.label))}`;
936
+ }
930
937
  if (step.type === 'randomValue') {
931
938
  const scope = variableContext.getStore();
932
939
  const context = replayContext.getStore();
@@ -1746,6 +1753,7 @@ export async function replayAppiumScript(
1746
1753
  };
1747
1754
  const context = {
1748
1755
  randomValues: new RandomValueGenerator(),
1756
+ stopwatches: new ReplayStopwatches(),
1749
1757
  screenshotReport: (runOptions.screenshotReport ?? loadConfig().appium.screenshotReport) === true,
1750
1758
  visualCaptureNodes: new Set([script, ...scripts.values()].flatMap(item => item.steps.flatMap(step =>
1751
1759
  step.visualChange ? [step.id, step.visualChange.startStepId || '', step.visualChange.endStepId || ''] : []))),
@@ -50,6 +50,31 @@ test('replay repeats random nodes, passes literal values through child returns,
50
50
  assert.deepEqual(new Set(values), new Set(['{{literal}}', '第二句']));
51
51
  for (const value of values) assert.ok(result.output.includes(`stageLog:echo=${value}|${value}`));
52
52
  }
53
+ const timedChild: AppiumRecordedScriptRecord = { ...base, id: 'timed-child', name: '通用打点子流程', steps: [
54
+ { id: 'mark', type: 'stopwatch', label: '业务阶段', stopwatch: { timerId: 'test-timer-id', name: 'request', action: 'mark' } },
55
+ ] };
56
+ const timed: AppiumRecordedScriptRecord = { ...base, id: 'timed', name: '通用计时循环', steps: [
57
+ { id: 'loop', type: 'loop', label: '重复两轮', loop: { maxIterations: 2, exitWhen: 'never' },
58
+ flow: { nodeKind: 'condition', yesTargetId: 'start', noTargetId: 'done' } },
59
+ { id: 'start', type: 'stopwatch', label: '开始', stopwatch: { timerId: 'test-timer-id', name: 'request', action: 'start' },
60
+ flow: { parentConditionId: 'loop', parentBranch: 'yes' } },
61
+ { id: 'child', type: 'runScript', label: '子流程打点', value: 'timed-child',
62
+ flow: { parentConditionId: 'loop', parentBranch: 'yes' } },
63
+ { id: 'end', type: 'stopwatch', label: '结束', stopwatch: { timerId: 'test-timer-id', name: 'request', action: 'end' },
64
+ flow: { parentConditionId: 'loop', parentBranch: 'yes' } },
65
+ { id: 'done', type: 'noop', label: '完成' },
66
+ ] };
67
+ for (let attempt = 0; attempt < 2; attempt++) {
68
+ const result = await replayAppiumScript(timed, 'fake-device', undefined, undefined,
69
+ { screenshotReport: false, reportSummaryEnabled: false, linkedScripts: [timedChild] });
70
+ assert.equal(result.success, true, result.output);
71
+ const records = [...result.output.matchAll(/TIMER:(\{[^\n]+\})/g)].map(match => JSON.parse(match[1]!));
72
+ assert.deepEqual(records.map(item => [item.run, item.action]), [
73
+ [1, 'start'], [1, 'mark'], [1, 'end'], [2, 'start'], [2, 'mark'], [2, 'end'],
74
+ ]);
75
+ assert.ok(records.every(item => Number.isFinite(item.elapsedMs) && Number.isFinite(item.intervalMs)));
76
+ assert.ok((await readFile(result.reportPath, 'utf8')).includes('TIMER:'));
77
+ }
53
78
  const exhausted = await run({ ...script, steps: script.steps.map(step => step.type === 'loop'
54
79
  ? { ...step, loop: { maxIterations: 3, exitWhen: 'never' } } : step) });
55
80
  assert.equal(exhausted.success, false);
@@ -13,6 +13,7 @@ import { validateVariables, validateExtraction, validateReturns, type TestVariab
13
13
  import { getPresetVariables, savePresetVariables, deleteScriptVariables } from './variable-store';
14
14
  import { validateImageCheck, type ImageCheckConfig } from '../../src/appium-recorder/image-check';
15
15
  import { validateRandomValue, type RandomValueConfig } from '../../src/appium-recorder/random-value';
16
+ import { validateStopwatch, remapStopwatchIds, type StopwatchConfig } from '../../src/appium-recorder/stopwatch';
16
17
 
17
18
  export type AppiumRecordedStepRecord = {
18
19
  mergeUndo?: import('../../src/appium-recorder/types').BranchMergeUndo;
@@ -55,6 +56,7 @@ export type AppiumRecordedStepRecord = {
55
56
  | 'noop'
56
57
  | 'extractVariable'
57
58
  | 'randomValue'
59
+ | 'stopwatch'
58
60
  | 'log'
59
61
  | 'visualChange';
60
62
  label: string;
@@ -100,6 +102,7 @@ export type AppiumRecordedStepRecord = {
100
102
  imageCheck?: ImageCheckConfig;
101
103
  extractVariable?: VariableExtraction;
102
104
  randomValue?: RandomValueConfig;
105
+ stopwatch?: StopwatchConfig;
103
106
  parameters?: TestVariable[];
104
107
  returns?: ScriptReturn[];
105
108
  keyCode?: number;
@@ -393,6 +396,7 @@ export function saveAppiumRecordedScript(input: {
393
396
  if (step.type === 'imageCheck') validateImageCheck(step.imageCheck);
394
397
  if (step.type === 'extractVariable') validateExtraction(step.extractVariable);
395
398
  if (step.type === 'randomValue') validateRandomValue(step.randomValue, { allowEmptySensitiveText: true });
399
+ if (step.type === 'stopwatch') validateStopwatch(step.stopwatch);
396
400
  if (step.type === 'runScript') { validateVariables(step.parameters); validateReturns(step.returns); }
397
401
  }
398
402
  validateLoopSteps(steps);
@@ -516,8 +520,10 @@ export function importAppiumRecordedScripts(inputs: Array<{
516
520
  });
517
521
  const importedIds = new Map(planned.filter(item => item.sourceId).map(item => [item.sourceId, item.id]));
518
522
 
523
+ const timerIds = new Map(planned.flatMap(input => input.steps.filter(step => step.stopwatch?.action === 'start' && step.stopwatch.timerId)
524
+ .map(step => [step.stopwatch!.timerId, crypto.randomUUID()])));
519
525
  return planned.map((input) => {
520
- const steps = input.steps.map(step => (
526
+ const steps = remapStopwatchIds(input.steps, timerIds).map(step => (
521
527
  step.type === 'runScript' && step.value && importedIds.has(step.value)
522
528
  ? { ...step, value: importedIds.get(step.value) }
523
529
  : step
@@ -0,0 +1,74 @@
1
+ import assert from 'node:assert/strict';
2
+ import { test } from 'node:test';
3
+ import { ReplayStopwatches } from './stopwatch';
4
+ import { defaultStopwatch, remapStopwatchIds, validateStopwatch, type StopwatchConfig } from '../../src/appium-recorder/stopwatch';
5
+ import { createFlowClipboard, pasteFlowClipboard } from '../../src/appium-recorder/flow-copy';
6
+ import type { AppiumRecordedStep } from '../../src/appium-recorder/types';
7
+ import { mkdtemp, rm } from 'node:fs/promises';
8
+ import { tmpdir } from 'node:os';
9
+ import { join } from 'node:path';
10
+
11
+ test('IDs isolate same-name timers; renaming never changes an association or loop count', () => {
12
+ const timers = new ReplayStopwatches();
13
+ const record = (action: StopwatchConfig['action'], now: number, timerId = 'id-a', name = '同名') => timers.record({ timerId, name, action }, action, now);
14
+ assert.deepEqual(record('start', 1000), { timerId: 'id-a', name: '同名', action: 'start', point: 'start', run: 1,
15
+ at: '1970-01-01T00:00:01.000Z', elapsedMs: 0, intervalMs: 0 });
16
+ record('start', 1200, 'id-b');
17
+ assert.deepEqual(record('mark', 1400, 'id-a', '改名'), { timerId: 'id-a', name: '同名', action: 'mark', point: 'mark', run: 1,
18
+ at: '1970-01-01T00:00:01.400Z', elapsedMs: 400, intervalMs: 400 });
19
+ assert.equal(record('end', 2000).intervalMs, 600);
20
+ assert.equal(record('end', 2200, 'id-b').elapsedMs, 1000);
21
+ assert.throws(() => record('mark', 2300), /尚未开始/);
22
+ assert.throws(() => record('mark', 2300, 'wrong-id', '同名'), /尚未开始/);
23
+ assert.equal(record('start', 2400, 'id-a', '重命名').run, 2);
24
+ assert.equal(record('start', 2500).restarted, true);
25
+ assert.equal(record('end', 2600).elapsedMs, 100);
26
+ assert.throws(() => new ReplayStopwatches().record({ timerId: 'id-a', name: '同名', action: 'end' }, 'end'), /尚未开始/);
27
+ const defaults = defaultStopwatch();
28
+ assert.notEqual(defaults.timerId, defaultStopwatch().timerId);
29
+ for (const config of [undefined, { ...defaults, name: '' }, { ...defaults, action: 'toString' },
30
+ { ...defaults, timerId: '' }, { name: 'old', action: 'start', point: 'old' }]) {
31
+ assert.throws(() => validateStopwatch(config as StopwatchConfig));
32
+ }
33
+ });
34
+
35
+ const steps: AppiumRecordedStep[] = [
36
+ { id: 'start', type: 'stopwatch', label: '开始', stopwatch: { timerId: 'original', name: '同名', action: 'start' } },
37
+ { id: 'mark', type: 'stopwatch', label: '打点', stopwatch: { timerId: 'original', name: '同名', action: 'mark' } },
38
+ { id: 'end', type: 'stopwatch', label: '结束', stopwatch: { timerId: 'original', name: '同名', action: 'end' } },
39
+ ];
40
+
41
+ test('copy/paste creates a new ID and remaps copied references; single marks retain explicit association', () => {
42
+ const pasted = pasteFlowClipboard(steps, createFlowClipboard(steps, [0, 1, 2]), { afterIndex: 2 });
43
+ assert.equal(pasted[0]!.stopwatch!.timerId, 'original');
44
+ const id = pasted[3]!.stopwatch!.timerId;
45
+ assert.notEqual(id, 'original');
46
+ assert.ok(pasted.slice(3).every(step => step.stopwatch!.timerId === id));
47
+ assert.equal(remapStopwatchIds([steps[1]!])[0]!.stopwatch!.timerId, 'original');
48
+ const duplicate = remapStopwatchIds(steps);
49
+ assert.notEqual(duplicate[0]!.stopwatch!.timerId, id);
50
+ assert.ok(duplicate.every(step => step.stopwatch!.timerId === duplicate[0]!.stopwatch!.timerId));
51
+ assert.equal(steps[0]!.stopwatch!.timerId, 'original');
52
+ });
53
+
54
+ test('batch import remaps timer IDs across scripts and keeps imported copies independent', async () => {
55
+ const root = await mkdtemp(join(tmpdir(), 'stopwatch-import-'));
56
+ const previous = process.env.ANDROID_MIDSCENE_DATA_ROOT;
57
+ process.env.ANDROID_MIDSCENE_DATA_ROOT = root;
58
+ try {
59
+ const { importAppiumRecordedScripts } = await import('./repository');
60
+ const inputs = [
61
+ { sourceId: 'parent', name: '父脚本', appPackage: 'example.app', steps: [steps[0]!, { id: 'call', type: 'runScript' as const, label: '子脚本', value: 'child' }] },
62
+ { sourceId: 'child', name: '子脚本', appPackage: 'example.app', steps: steps.slice(1) },
63
+ ];
64
+ const [parent, child] = importAppiumRecordedScripts(inputs);
65
+ const id = parent!.steps[0]!.stopwatch!.timerId;
66
+ assert.notEqual(id, 'original');
67
+ assert.ok(child!.steps.every(step => step.stopwatch!.timerId === id));
68
+ assert.equal(parent!.steps[1]!.value, child!.id);
69
+ assert.notEqual(importAppiumRecordedScripts(inputs)[0]!.steps[0]!.stopwatch!.timerId, id);
70
+ } finally {
71
+ if (previous === undefined) delete process.env.ANDROID_MIDSCENE_DATA_ROOT; else process.env.ANDROID_MIDSCENE_DATA_ROOT = previous;
72
+ await rm(root, { recursive: true, force: true });
73
+ }
74
+ });
@@ -0,0 +1,24 @@
1
+ import { STOPWATCH_ACTIONS, validateStopwatch, type StopwatchConfig } from '../../src/appium-recorder/stopwatch';
2
+
3
+ // System-generated IDs link timers within one replay, including linked scripts.
4
+ export class ReplayStopwatches {
5
+ private readonly active = new Map<string, { name: string; started: number; last: number; run: number }>();
6
+ private readonly counts = new Map<string, number>();
7
+ record(input: StopwatchConfig, point = STOPWATCH_ACTIONS[input.action], now = Date.now()) {
8
+ const config = validateStopwatch(input);
9
+ const timerId = config.timerId.trim();
10
+ const previous = this.active.get(timerId);
11
+ if (config.action === 'start') {
12
+ const run = (this.counts.get(timerId) || 0) + 1;
13
+ this.counts.set(timerId, run);
14
+ this.active.set(timerId, { name: config.name.trim(), started: now, last: now, run });
15
+ } else if (!previous) throw new Error(`计时器「${timerId}」尚未开始或已经结束`);
16
+ const timer = this.active.get(timerId)!;
17
+ const result = { timerId, name: timer.name, run: timer.run, action: config.action, point: point.trim() || STOPWATCH_ACTIONS[config.action], at: new Date(now).toISOString(),
18
+ elapsedMs: Math.max(0, now - timer.started), intervalMs: Math.max(0, now - timer.last),
19
+ ...(config.action === 'start' && previous ? { restarted: true } : {}),
20
+ };
21
+ if (config.action === 'end') this.active.delete(timerId); else timer.last = now;
22
+ return result;
23
+ }
24
+ }
package/src/App.vue CHANGED
@@ -42,6 +42,7 @@ const AutomationPage = defineAsyncComponent(() => import('./pages/AutomationPage
42
42
  const AppiumPage = defineAsyncComponent(() => import('./appium-recorder/AppiumPage.vue'));
43
43
  const ArtemisPage = defineAsyncComponent(() => import('./pages/ArtemisPage.vue'));
44
44
  const ConfigPage = defineAsyncComponent(() => import('./pages/ConfigPage.vue'));
45
+ const MidsceneConfigPanel = defineAsyncComponent(() => import('./components/config/MidsceneConfigPanel.vue'));
45
46
  const GeneratorPage = defineAsyncComponent(() => import('./pages/GeneratorPage.vue'));
46
47
  const HelpCenter = defineAsyncComponent(() => import('./components/help/HelpCenter.vue'));
47
48
  import type {
@@ -52,7 +53,7 @@ import type {
52
53
  } from './types';
53
54
 
54
55
  const ACTIVE_MENU_STORAGE_KEY = 'android-midscene-automation:active-menu';
55
- const menuKeys: MenuKey[] = ['appium', 'artemis', 'generator', 'automation', 'analysis', 'config', 'about'];
56
+ const menuKeys: MenuKey[] = ['appium', 'artemis', 'generator', 'automation', 'midscene-config', 'analysis', 'config', 'about'];
56
57
  const storedMenu = window.localStorage.getItem(ACTIVE_MENU_STORAGE_KEY) as MenuKey | null;
57
58
  const activeMenu = ref<MenuKey>(storedMenu && menuKeys.includes(storedMenu) ? storedMenu : 'generator');
58
59
  const activeGeneratorMode = ref<GeneratorMode>('ai');
@@ -125,7 +126,8 @@ const menuItems = [
125
126
  { key: 'appium', label: 'Appium', icon: Monitor },
126
127
  { key: 'artemis', label: 'Artemis', icon: Monitor },
127
128
  { key: 'generator', label: '测试脚本生成', icon: Operation },
128
- { key: 'automation', label: '自动化测试', icon: Monitor },
129
+ { key: 'automation', label: '自动化测试', icon: VideoPlay },
130
+ { key: 'midscene-config', label: 'Midscene参数配置', icon: Setting },
129
131
  { key: 'analysis', label: '分析页', icon: DataAnalysis },
130
132
  { key: 'config', label: '参数配置', icon: Setting },
131
133
  { key: 'about', label: '关于', icon: InfoFilled },
@@ -894,7 +896,7 @@ onUnmounted(() => {
894
896
  'page-body--artemis': activeMenu === 'artemis',
895
897
  }"
896
898
  >
897
- <el-alert v-if="activeMenu !== 'appium' && activeMenu !== 'artemis' && activeMenu !== 'config' && activeMenu !== 'about' && errorMessage" type="error" :closable="false" show-icon class="page-alert">
899
+ <el-alert v-if="activeMenu !== 'appium' && activeMenu !== 'artemis' && activeMenu !== 'config' && activeMenu !== 'midscene-config' && activeMenu !== 'about' && errorMessage" type="error" :closable="false" show-icon class="page-alert">
898
900
  <template #title>{{ errorMessage }}</template>
899
901
  </el-alert>
900
902
 
@@ -929,7 +931,19 @@ onUnmounted(() => {
929
931
  @clear-all="clearGeneratorPage"
930
932
  />
931
933
 
932
- <div v-if="activeMenu === 'config' && !configReady && !configResource.error.value" class="page-loading" role="status">正在加载参数配置…</div>
934
+ <div v-if="(activeMenu === 'config' || activeMenu === 'midscene-config') && !configReady && !configResource.error.value" class="page-loading" role="status">正在加载参数配置…</div>
935
+
936
+ <MidsceneConfigPanel
937
+ v-if="visitedMenus.has('midscene-config') && configReady"
938
+ v-show="activeMenu === 'midscene-config'"
939
+ role="region"
940
+ aria-label="Midscene参数配置"
941
+ :config-form="configForm"
942
+ :testing-model-key="testingModelKey"
943
+ :model-test-status="modelTestStatus"
944
+ @test-model="testModel"
945
+ @update-midscene-model-provider="updateMidsceneModelProvider"
946
+ />
933
947
 
934
948
  <ConfigPage
935
949
  v-if="visitedMenus.has('config') && configReady"
@@ -950,7 +964,6 @@ onUnmounted(() => {
950
964
  @edit-app-preset="editAppPreset"
951
965
  @delete-app-preset="removeAppPreset"
952
966
  @cancel-app-preset-edit="resetAppPresetForm"
953
- @update-midscene-model-provider="updateMidsceneModelProvider"
954
967
  />
955
968
 
956
969
  <AutomationPage
@@ -40,6 +40,8 @@ import RecorderWorkspace from './components/RecorderWorkspace.vue';
40
40
  import FlowCanvas from './components/FlowCanvas.vue';
41
41
  import LongPressSettings from './components/LongPressSettings.vue';
42
42
  import StageLogSettings from './components/StageLogSettings.vue';
43
+ import StopwatchSettings from './components/StopwatchSettings.vue';
44
+ import { defaultStopwatch, validateStopwatch, stopwatchTargetsKey, remapStopwatchIds } from './stopwatch';
43
45
  import TextClickSettings from './components/TextClickSettings.vue';
44
46
  import { textClickSelector } from './text-click';
45
47
  import { DEFAULT_LOG_PREFIX, validateStageLog } from './stage-log';
@@ -224,6 +226,13 @@ const form = reactive({
224
226
  appPackage: '',
225
227
  appActivity: '',
226
228
  });
229
+ const stopwatchTargets = computed(() => [
230
+ ...scripts.value.filter(script => script.id !== selectedScriptId.value),
231
+ { name: form.name || '当前脚本', steps: steps.value },
232
+ ].flatMap(script => script.steps.flatMap((step, index) => step.type === 'stopwatch' && step.stopwatch?.action === 'start' && step.stopwatch.timerId
233
+ ? [{ timerId: step.stopwatch.timerId, name: step.stopwatch.name,
234
+ label: `${step.stopwatch.name} · ${script.name} · 节点 ${index + 1} · ${step.stopwatch.timerId}` }] : [])));
235
+ provide(stopwatchTargetsKey, stopwatchTargets);
227
236
  const scriptVariables = shallowRef<TestVariable[]>([]);
228
237
  const globalVariables = shallowRef<TestVariable[]>([]);
229
238
  const variablePresetsLoading = shallowRef(false);
@@ -1631,6 +1640,22 @@ async function addAction(
1631
1640
  if (result) return insertStep({ ...step }, index, branchTarget);
1632
1641
  return;
1633
1642
  }
1643
+ if (action === 'stopwatch') {
1644
+ const step = reactive<AppiumRecordedStep>({ id: createStepId(), type: 'stopwatch', label: '计时打点', stopwatch: defaultStopwatch(), flow: { nodeKind: 'action' } });
1645
+ const result = await ElMessageBox({
1646
+ title: '添加计时打点',
1647
+ message: h(ElForm, { labelPosition: 'top', style: { width: 'min(380px, calc(100vw - 64px))' } }, () => h(StopwatchSettings, { step, targets: stopwatchTargets.value, onUpdate: patch => Object.assign(step, patch) })),
1648
+ showCancelButton: true, confirmButtonText: '添加', cancelButtonText: '取消',
1649
+ beforeClose: (action, _instance, done) => {
1650
+ if (action === 'confirm') {
1651
+ try { validateStopwatch(step.stopwatch); } catch (error) { ElMessage.warning((error as Error).message); return; }
1652
+ }
1653
+ done();
1654
+ },
1655
+ }).catch(() => null);
1656
+ if (result) return insertStep({ ...step, stopwatch: { ...step.stopwatch! } }, index, branchTarget);
1657
+ return;
1658
+ }
1634
1659
  if (action === 'randomValue') {
1635
1660
  const step = reactive<AppiumRecordedStep>(pendingRandomValue.value?.step || {
1636
1661
  id: createStepId(), type: 'randomValue', label: '获取随机值', randomValue: { ...defaultRandomValue(), name: '' }, flow: { nodeKind: 'action' },
@@ -2044,7 +2069,7 @@ async function duplicateScript(script: AppiumRecordedScript) {
2044
2069
  appPackage: script.appPackage,
2045
2070
  appActivity: script.appActivity,
2046
2071
  deviceId: script.deviceId,
2047
- steps: cloneScriptSteps(script.steps),
2072
+ steps: remapStopwatchIds(cloneScriptSteps(script.steps)),
2048
2073
  });
2049
2074
  await loadScripts();
2050
2075
  ElMessage.success(`已复制为「${payload.script.name}」`);
@@ -7,6 +7,7 @@ export const actionDescriptions: Record<InsertAction, string> = {
7
7
  input: '向当前选中的输入组件写入指定文字,支持 {{变量名}} 引用。',
8
8
  extractVariable: '读取组件文字或属性,保存到当前脚本变量供后续节点引用。',
9
9
  randomValue: '从预设文本或导入的 TXT 中抽取一条,或生成随机整数、UUID,写入脚本变量。每次执行抽取一次,放在循环体内可每轮重新取值。',
10
+ stopwatch: '通用计时:通过系统生成的计时器 ID 关联开始、打点和结束节点,名称仅用于显示;日志输出绝对时间、距开始和距上次打点的毫秒数。与等待节点配合,可测量页面加载、接口返回或聊天响应等流程。',
10
11
  clearInput: '清空当前选中输入组件的内容。',
11
12
  coordinateTap: '点击设备屏幕上的指定 X、Y 坐标。节点中可修改坐标,页面位置变化后需重新确认。',
12
13
  longPress: '长按指定元素或屏幕坐标,可设置按住时长,默认按元素定位。',
@@ -10,6 +10,7 @@ import BranchTimeoutSettings from './BranchTimeoutSettings.vue';
10
10
  import { DEFAULT_NODE_TIMEOUT_MS } from '../node-timeout';
11
11
  import LongPressSettings from './LongPressSettings.vue';
12
12
  import StageLogSettings from './StageLogSettings.vue';
13
+ import StopwatchSettings from './StopwatchSettings.vue';
13
14
  import LoopSettings from './LoopSettings.vue';
14
15
  import BreakLoopSettings from './BreakLoopSettings.vue';
15
16
  import VariableExtractionSettings from './VariableExtractionSettings.vue';
@@ -60,7 +61,7 @@ const selectorSummary = computed(() => {
60
61
  return `${selector.strategy} · ${value}${props.step.contextSelector ? ' · 含父级' : ''}`;
61
62
  });
62
63
  const supportsTimeout = computed(() => ![
63
- 'delay', 'longPress', 'stopApp', 'log', 'openGallery', 'endFlow', 'loop', 'breakLoop', 'continueLoop', 'aiRecognition', 'randomValue',
64
+ 'delay', 'longPress', 'stopApp', 'log', 'stopwatch', 'openGallery', 'endFlow', 'loop', 'breakLoop', 'continueLoop', 'aiRecognition', 'randomValue',
64
65
  ].includes(props.step.type));
65
66
 
66
67
  function defaultKind(): FlowKind {
@@ -188,6 +189,7 @@ function patchSelector(patch: Partial<AppiumSelector>) {
188
189
  </div>
189
190
  </template>
190
191
  <StageLogSettings v-if="step.type === 'log'" :step="step" :disabled="disabled" @update="patchStep" />
192
+ <StopwatchSettings v-if="step.type === 'stopwatch'" :step="step" :disabled="disabled" @update="patchStep" />
191
193
  <VariableExtractionSettings v-if="step.type === 'extractVariable'" :step="step" :disabled="disabled" @update="patchStep" />
192
194
  <RandomValueSettings v-if="step.type === 'randomValue'" :step="step" :disabled="disabled" @update="patchStep" />
193
195
  <ScriptParameterSettings v-if="step.type === 'runScript'" :step="step" :disabled="disabled" @update="patchStep" />
@@ -127,6 +127,7 @@ const insertActionGroups: FlowActionGroup[] = [
127
127
  ],
128
128
  },
129
129
  { type: 'log', label: '输出日志' },
130
+ { type: 'stopwatch', label: '计时打点' },
130
131
  { type: 'runScript', label: '连接脚本' },
131
132
  ],
132
133
  },
@@ -0,0 +1,40 @@
1
+ <script setup lang="ts">
2
+ import { computed, inject } from 'vue';
3
+ import { defaultStopwatch, stopwatchTargetsKey, STOPWATCH_ACTIONS, type StopwatchConfig, type StopwatchTarget } from '../stopwatch';
4
+ import type { AppiumRecordedStep } from '../types';
5
+ const props = defineProps<{ step: AppiumRecordedStep; disabled?: boolean; targets?: StopwatchTarget[] }>();
6
+ const emit = defineEmits<{ update: [patch: Partial<AppiumRecordedStep>] }>();
7
+ const providedTargets = inject(stopwatchTargetsKey, computed(() => []));
8
+ const targets = computed(() => props.targets ?? providedTargets.value);
9
+ const config = computed(() => props.step.stopwatch ?? defaultStopwatch());
10
+ const selected = computed(() => targets.value.find(target => target.timerId === config.value.timerId));
11
+ function patch(value: Partial<StopwatchConfig>) { emit('update', { stopwatch: { ...config.value, ...value } }); }
12
+ function changeAction(action: StopwatchConfig['action']) {
13
+ if (action === config.value.action) return;
14
+ const wasStart = config.value.action === 'start';
15
+ patch({ action, ...(action === 'start' ? { timerId: crypto.randomUUID() } : wasStart ? { timerId: '' } : {}) });
16
+ }
17
+ function selectTimer(timerId: string) {
18
+ const target = targets.value.find(item => item.timerId === timerId);
19
+ patch({ timerId, ...(target ? { name: target.name } : {}) });
20
+ }
21
+ </script>
22
+
23
+ <template>
24
+ <el-form-item label="计时操作">
25
+ <el-select :model-value="config.action" :disabled="disabled" aria-label="计时操作" @update:model-value="changeAction">
26
+ <el-option v-for="(label, value) in STOPWATCH_ACTIONS" :key="value" :label="label" :value="value" />
27
+ </el-select>
28
+ </el-form-item>
29
+ <el-form-item v-if="config.action !== 'start'" label="关联计时器" :error="config.timerId && !selected ? '关联的开始节点不存在,请重新选择' : ''">
30
+ <el-select :model-value="config.timerId" :disabled="disabled" filterable placeholder="请选择开始计时节点" aria-label="关联计时器" @update:model-value="selectTimer">
31
+ <el-option v-for="target in targets" :key="target.timerId" :label="target.label" :value="target.timerId" />
32
+ </el-select>
33
+ </el-form-item>
34
+ <el-form-item label="计时器名称">
35
+ <el-input :model-value="config.action === 'start' ? config.name : selected?.name || config.name" :readonly="config.action !== 'start'" :disabled="disabled" maxlength="80" aria-label="计时器名称" @update:model-value="patch({ name: String($event) })" />
36
+ </el-form-item>
37
+ <el-form-item label="计时器 ID">
38
+ <el-input :model-value="config.timerId" readonly aria-label="计时器 ID" placeholder="选择开始节点后显示" />
39
+ </el-form-item>
40
+ </template>
@@ -1,5 +1,6 @@
1
1
  import type { AppiumRecordedStep } from './types';
2
2
  import { insertBeforeSharedStep } from './flow-insert';
3
+ import { remapStopwatchIds } from './stopwatch';
3
4
 
4
5
  export type FlowBranch = 'yes' | 'no';
5
6
 
@@ -178,7 +179,7 @@ export function pasteFlowClipboard(
178
179
  const pairId = createId();
179
180
  visualChangePairKeys(step).forEach((key) => pairMap.set(key, pairId));
180
181
  });
181
- const copies = clipboard.steps.map((source) => {
182
+ const copies = remapStopwatchIds(clipboard.steps.map((source) => {
182
183
  const step = clone(source);
183
184
  // 合并记录引用原流程 ID,不能随节点复制到另一条流程。
184
185
  delete step.mergeUndo;
@@ -221,7 +222,7 @@ export function pasteFlowClipboard(
221
222
  };
222
223
  }
223
224
  return step;
224
- });
225
+ }));
225
226
 
226
227
  const copiedBySourceId = new Map(clipboard.steps.map((step, index) => [step.id, copies[index]]));
227
228
  const copiedRoots = clipboard.rootIds
@@ -51,6 +51,7 @@ export type InsertAction =
51
51
  | 'runScript'
52
52
  | 'extractVariable'
53
53
  | 'randomValue'
54
+ | 'stopwatch'
54
55
  | 'noop'
55
56
  | 'log'
56
57
  | 'visualChangeStart'
@@ -7,6 +7,7 @@ import { DEFAULT_LOG_PREFIX } from './stage-log';
7
7
  import { imageCheckSummary } from './image-check';
8
8
  import { isAiBranchEnabled } from './ai-recognition';
9
9
  import { randomValueSummary } from './random-value';
10
+ import { STOPWATCH_ACTIONS } from './stopwatch';
10
11
 
11
12
  export function isBooleanCondition(step: Pick<AppiumRecordedStep, 'type' | 'aiBranchEnabled'>) {
12
13
  return isNativeStateCondition(step) || (step.type === 'aiRecognition' && isAiBranchEnabled(step)) || step.type === 'textClick' || step.type === 'imageCheck';
@@ -14,7 +15,7 @@ export function isBooleanCondition(step: Pick<AppiumRecordedStep, 'type' | 'aiBr
14
15
 
15
16
  export function defaultFlowKind(step: AppiumRecordedStep): FlowKind {
16
17
  if (step.type === 'aiRecognition') return isAiBranchEnabled(step) ? 'condition' : 'action';
17
- if (step.type === 'extractVariable' || step.type === 'randomValue') return 'action';
18
+ if (step.type === 'extractVariable' || step.type === 'randomValue' || step.type === 'stopwatch') return 'action';
18
19
  if (step.type === 'loop') return 'condition';
19
20
  if (step.type === 'breakLoop' || step.type === 'continueLoop') return 'action';
20
21
  if (step.type === 'log' || step.type === 'openGallery' || step.type === 'endFlow') return 'action';
@@ -75,12 +76,14 @@ export function flowTypeLabel(step: AppiumRecordedStep) {
75
76
  log: '输出日志',
76
77
  extractVariable: '提取变量',
77
78
  randomValue: '获取随机值',
79
+ stopwatch: '计时打点',
78
80
  visualChange: '检测画面变化',
79
81
  };
80
82
  return labelMap[step.type] || step.type;
81
83
  }
82
84
 
83
85
  export function flowStepMeta(step: AppiumRecordedStep) {
86
+ if (step.type === 'stopwatch') return `${step.stopwatch?.name || '未命名'}${step.stopwatch?.timerId ? '' : '(未关联)'} · ${STOPWATCH_ACTIONS[step.stopwatch?.action || 'start']}`;
84
87
  if (step.type === 'randomValue') return randomValueSummary(step.randomValue);
85
88
  if (step.type === 'imageCheck') return imageCheckSummary(step.imageCheck);
86
89
  if (step.type === 'extractVariable') return `${step.extractVariable?.attribute || 'text'} → ${step.extractVariable?.name || '未设置变量名'}`;
@@ -0,0 +1,27 @@
1
+ import type { InjectionKey, Ref } from 'vue';
2
+
3
+ export type StopwatchConfig = { timerId: string; name: string; action: 'start' | 'mark' | 'end' };
4
+ export type StopwatchTarget = { timerId: string; name: string; label: string };
5
+ export const stopwatchTargetsKey: InjectionKey<Readonly<Ref<StopwatchTarget[]>>> = Symbol('stopwatch-targets');
6
+ export const STOPWATCH_ACTIONS = { start: '开始计时', mark: '记录时间点', end: '结束计时' };
7
+ export function defaultStopwatch(): StopwatchConfig {
8
+ return { timerId: crypto.randomUUID(), name: '计时器1', action: 'start' };
9
+ }
10
+ export function validateStopwatch(config?: StopwatchConfig) {
11
+ if (!config || typeof config.name !== 'string' || !config.name.trim() || config.name.length > 80
12
+ || !Object.prototype.hasOwnProperty.call(STOPWATCH_ACTIONS, config.action)) {
13
+ throw new Error('请填写计时器名称并选择有效操作');
14
+ }
15
+ if (typeof config.timerId !== 'string' || !config.timerId.trim() || config.timerId.length > 160) {
16
+ throw new Error('请通过关联计时器选择开始节点;计时器 ID 由系统生成');
17
+ }
18
+ return config;
19
+ }
20
+
21
+ // Copying a start creates a new timer; references copied with it follow the new ID.
22
+ export function remapStopwatchIds<T extends { stopwatch?: StopwatchConfig }>(steps: T[], ids?: Map<string, string>): T[] {
23
+ const replacements = ids ?? new Map(steps.filter(step => step.stopwatch?.action === 'start' && step.stopwatch.timerId)
24
+ .map(step => [step.stopwatch!.timerId, crypto.randomUUID()]));
25
+ return steps.map(step => step.stopwatch && replacements.has(step.stopwatch.timerId)
26
+ ? { ...step, stopwatch: { ...step.stopwatch, timerId: replacements.get(step.stopwatch.timerId)! } } : step);
27
+ }
@@ -2,6 +2,7 @@ import type { AiInvalidResultBranch, AiObservationConfig } from './ai-recognitio
2
2
  import type { TestVariable, VariableExtraction, ScriptReturn } from './variables';
3
3
  import type { ImageCheckConfig } from './image-check';
4
4
  import type { RandomValueConfig } from './random-value';
5
+ import type { StopwatchConfig } from './stopwatch';
5
6
 
6
7
  export type AppiumBounds = {
7
8
  left: number;
@@ -110,6 +111,7 @@ export type AppiumRecordedStep = {
110
111
  | 'noop'
111
112
  | 'extractVariable'
112
113
  | 'randomValue'
114
+ | 'stopwatch'
113
115
  | 'log'
114
116
  | 'visualChange';
115
117
  label: string;
@@ -122,6 +124,7 @@ export type AppiumRecordedStep = {
122
124
  logPrefix?: string;
123
125
  extractVariable?: VariableExtraction;
124
126
  randomValue?: RandomValueConfig;
127
+ stopwatch?: StopwatchConfig;
125
128
  parameters?: TestVariable[];
126
129
  returns?: ScriptReturn[];
127
130
  keyCode?: number;
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { DataAnalysis, Grid, Monitor, Operation, InfoFilled, Setting } from '@element-plus/icons-vue';
2
+ import { DataAnalysis, Grid, Monitor, Operation, InfoFilled, Setting, VideoPlay } from '@element-plus/icons-vue';
3
3
  import type { MenuKey } from '../types';
4
4
 
5
5
  defineProps<{ activeMenu: MenuKey; collapsed: boolean }>();
@@ -12,14 +12,25 @@ defineEmits<{ select: [key: string] }>();
12
12
  <div class="layout-sidebar__logo" aria-hidden="true">A</div>
13
13
  <span v-if="!collapsed" class="layout-sidebar__brand" title="移动自动化控制台">移动自动化<span>控制台</span></span>
14
14
  </div>
15
- <el-menu :default-active="activeMenu" :default-openeds="['overview', 'midscene']" :collapse="collapsed"
15
+ <el-menu :default-active="activeMenu" :default-openeds="['overview', 'laboratory', 'midscene']" :collapse="collapsed"
16
16
  :collapse-transition="false" class="layout-menu" @select="$emit('select', $event)">
17
17
  <el-menu-item index="appium" aria-label="Appium"><el-icon><Monitor /></el-icon><template #title>Appium</template></el-menu-item>
18
- <el-menu-item index="artemis" aria-label="Artemis"><el-icon><Monitor /></el-icon><template #title>Artemis</template></el-menu-item>
19
- <el-sub-menu index="midscene" aria-label="Midscene">
20
- <template #title><el-icon><Operation /></el-icon><span>Midscene</span></template>
21
- <el-menu-item index="generator" aria-label="测试脚本生成"><el-icon><Operation /></el-icon><template #title>测试脚本生成</template></el-menu-item>
22
- <el-menu-item index="automation" aria-label="自动化测试"><el-icon><Monitor /></el-icon><template #title>自动化测试</template></el-menu-item>
18
+ <el-sub-menu index="laboratory" aria-label="实验室">
19
+ <template #title>
20
+ <el-icon>
21
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
22
+ <path d="M9 3h6M10 3v7L4.6 18.8A1.5 1.5 0 0 0 5.9 21h12.2a1.5 1.5 0 0 0 1.3-2.2L14 10V3M7 15h10" />
23
+ </svg>
24
+ </el-icon>
25
+ <span>实验室</span>
26
+ </template>
27
+ <el-menu-item index="artemis" aria-label="Artemis"><el-icon><Monitor /></el-icon><template #title>Artemis<span class="layout-menu__new">New</span></template></el-menu-item>
28
+ <el-sub-menu index="midscene" aria-label="Midscene">
29
+ <template #title><el-icon><Monitor /></el-icon><span>Midscene</span></template>
30
+ <el-menu-item index="generator" aria-label="测试脚本生成"><el-icon><Operation /></el-icon><template #title>测试脚本生成</template></el-menu-item>
31
+ <el-menu-item index="automation" aria-label="自动化测试"><el-icon><VideoPlay /></el-icon><template #title>自动化测试</template></el-menu-item>
32
+ <el-menu-item index="midscene-config" aria-label="Midscene参数配置"><el-icon><Setting /></el-icon><template #title><span class="layout-menu__label" title="参数配置">参数配置</span></template></el-menu-item>
33
+ </el-sub-menu>
23
34
  </el-sub-menu>
24
35
  <el-sub-menu index="overview" aria-label="概览">
25
36
  <template #title><el-icon><Grid /></el-icon><span>概览</span></template>
@@ -30,3 +41,22 @@ defineEmits<{ select: [key: string] }>();
30
41
  </el-menu>
31
42
  </aside>
32
43
  </template>
44
+
45
+ <style scoped>
46
+ .layout-menu__new {
47
+ margin-left: 6px;
48
+ color: var(--el-color-danger);
49
+ font-size: 11px;
50
+ font-weight: 600;
51
+ }
52
+
53
+ .layout-menu__label {
54
+ overflow: hidden;
55
+ text-overflow: ellipsis;
56
+ white-space: nowrap;
57
+ }
58
+
59
+ .layout-menu :deep(.el-sub-menu .el-sub-menu .el-menu-item) {
60
+ padding-left: 68px !important;
61
+ }
62
+ </style>
@@ -24,10 +24,12 @@ const activeSection = shallowRef<'basic' | 'models'>('basic');
24
24
  <template>
25
25
  <div class="appium-config-stack">
26
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>
27
+ <div class="appium-config-categories">
28
+ <el-radio-group v-model="activeSection" aria-label="Appium配置分类">
29
+ <el-radio value="basic">基础配置</el-radio>
30
+ <el-radio value="models">模型配置</el-radio>
31
+ </el-radio-group>
32
+ </div>
31
33
  <div v-if="saveStatus || saveFailed" class="appium-config-save-state">
32
34
  <span v-if="saveStatus" class="config-save-status" role="status">{{ saveStatus }}</span>
33
35
  <el-button v-if="saveFailed" link type="primary" @click="$emit('retrySave')">重试保存</el-button>
@@ -96,7 +98,10 @@ const activeSection = shallowRef<'basic' | 'models'>('basic');
96
98
  <style scoped>
97
99
  .config-save-status { font-size: 12px; font-weight: 400; color: var(--el-text-color-secondary); }
98
100
  .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; }
101
+ .appium-config-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-top: 16px; border-top: 1px solid var(--ui-border); }
102
+ .appium-config-categories { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 24px; }
103
+ .appium-config-categories :deep(.el-radio-group) { gap: 24px; }
104
+ .appium-config-categories :deep(.el-radio) { height: 40px; margin-right: 0; }
100
105
  .appium-config-save-state { display: flex; align-items: center; gap: 8px; }
101
106
  .appium-config-section { display: grid; gap: 14px; min-width: 0; }
102
107
  .appium-section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 0 4px; }
@@ -52,40 +52,55 @@ defineEmits<{
52
52
  <el-card shadow="never" class="config-module-card">
53
53
  <template #header>
54
54
  <div class="panel-header">
55
- <div class="panel-header__title">
56
- <span>预设 App 参数</span>
57
- <el-tag v-if="appPresetForm.id" size="small" type="warning">编辑中</el-tag>
58
- </div>
55
+ <span>预设 App 参数</span>
59
56
  </div>
60
57
  </template>
61
58
 
62
59
  <div class="app-preset-layout">
63
- <el-form label-position="top" :disabled="isSavingAppPreset" @submit.prevent="$emit('saveAppPreset')">
64
- <el-form-item label="App 名称">
65
- <el-input v-model="appPresetForm.name" placeholder="例如:示例 App" />
66
- </el-form-item>
67
- <el-form-item label="App 包名">
68
- <el-input v-model="appPresetForm.packageName" placeholder="例如:com.example.app" />
69
- </el-form-item>
70
- <div class="app-preset-actions">
71
- <el-button v-if="appPresetForm.id" :disabled="isSavingAppPreset" @click="$emit('cancelAppPresetEdit')">取消编辑</el-button>
72
- <el-button type="primary" native-type="submit" :loading="isSavingAppPreset">{{ appPresetForm.id ? '保存修改' : '添加' }}</el-button>
73
- </div>
74
- </el-form>
75
-
76
- <div class="app-preset-list">
77
- <div v-for="app in appPresets" :key="app.id" class="app-preset-row">
78
- <div class="app-preset-row__main">
79
- <strong>{{ app.name }}</strong>
80
- <span>{{ app.packageName }}</span>
60
+ <section class="app-preset-panel" aria-label="App 预设编辑">
61
+ <div class="panel-header panel-header--sub">
62
+ <h3>{{ appPresetForm.id ? '编辑 App' : '添加 App' }}</h3>
63
+ <el-tag v-if="appPresetForm.id" size="small" effect="plain">编辑中</el-tag>
81
64
  </div>
82
- <div class="script-row__actions">
83
- <el-button text size="small" :icon="Edit" :disabled="isSavingAppPreset" :aria-label="`编辑 ${app.name}`" @click="$emit('editAppPreset', app)" />
84
- <el-button text size="small" :icon="Delete" :disabled="isSavingAppPreset" :aria-label="`删除 ${app.name}`" @click="$emit('deleteAppPreset', app.id)" />
65
+ <el-form label-position="top" :disabled="isSavingAppPreset" @submit.prevent="$emit('saveAppPreset')">
66
+ <el-form-item label="App 名称">
67
+ <el-input v-model="appPresetForm.name" placeholder="例如:示例 App" />
68
+ </el-form-item>
69
+ <el-form-item label="App 包名">
70
+ <el-input v-model="appPresetForm.packageName" placeholder="例如:com.example.app" />
71
+ </el-form-item>
72
+ <div class="app-preset-actions">
73
+ <el-button v-if="appPresetForm.id" :disabled="isSavingAppPreset" @click="$emit('cancelAppPresetEdit')">取消编辑</el-button>
74
+ <el-button type="primary" native-type="submit" :loading="isSavingAppPreset">{{ appPresetForm.id ? '保存修改' : '添加' }}</el-button>
75
+ </div>
76
+ </el-form>
77
+ </section>
78
+
79
+ <section class="app-preset-panel app-preset-collection" aria-label="已保存的 App">
80
+ <div class="panel-header panel-header--sub">
81
+ <h3>已保存的 App</h3>
82
+ <el-tag size="small" type="info" effect="plain">{{ appPresets.length }} 个</el-tag>
85
83
  </div>
86
- </div>
87
- <el-empty v-if="!appPresets.length" description="暂无预设 App" />
88
- </div>
84
+ <el-table
85
+ :data="appPresets"
86
+ row-key="id"
87
+ :max-height="280"
88
+ :row-class-name="({ row }: { row: AppPreset }) => appPresetForm.id === row.id ? 'app-preset-row--editing' : ''"
89
+ empty-text="暂无预设 App"
90
+ aria-label="App 预设列表"
91
+ >
92
+ <el-table-column prop="name" label="App 名称" min-width="120" show-overflow-tooltip />
93
+ <el-table-column prop="packageName" label="App 包名" min-width="180" show-overflow-tooltip />
94
+ <el-table-column label="操作" width="88" align="right">
95
+ <template #default="{ row }">
96
+ <div class="app-preset-row__actions">
97
+ <el-button text size="small" :icon="Edit" :disabled="isSavingAppPreset" :aria-label="`编辑 ${row.name}`" :title="`编辑 ${row.name}`" @click="$emit('editAppPreset', row)" />
98
+ <el-button text size="small" :icon="Delete" :disabled="isSavingAppPreset" :aria-label="`删除 ${row.name}`" :title="`删除 ${row.name}`" @click="$emit('deleteAppPreset', row.id)" />
99
+ </div>
100
+ </template>
101
+ </el-table-column>
102
+ </el-table>
103
+ </section>
89
104
  </div>
90
105
  </el-card>
91
106
  </div>
@@ -96,11 +111,17 @@ defineEmits<{
96
111
  .runtime-config-form :deep(.el-form-item) { margin-bottom: 0; }
97
112
  @media (max-width: 1000px) { .runtime-config-form { grid-template-columns: minmax(0, 1fr); } }
98
113
 
99
- .app-preset-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
100
- .app-preset-actions { display: flex; justify-content: flex-end; margin-top: 4px; }
101
- .app-preset-layout .app-preset-list { margin-top: 0; padding-left: 24px; border-left: 1px solid var(--ui-border); }
102
- @media (max-width: 800px) {
114
+ .app-preset-layout { display: grid; grid-template-columns: minmax(0, 0.75fr) minmax(0, 1.25fr); gap: 24px; }
115
+ .app-preset-panel { min-width: 0; }
116
+ .app-preset-panel h3 { margin: 0; color: var(--ui-text); font-size: 14px; font-weight: 600; }
117
+ .app-preset-collection { padding-left: 24px; border-left: 1px solid var(--ui-border); }
118
+ .app-preset-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
119
+ .app-preset-actions :deep(.el-button + .el-button) { margin-left: 0; }
120
+ .app-preset-row__actions { display: flex; justify-content: flex-end; gap: 4px; }
121
+ .app-preset-row__actions :deep(.el-button) { width: 28px; height: 28px; margin: 0; padding: 0; }
122
+ .app-preset-collection :deep(.app-preset-row--editing) { --el-table-tr-bg-color: var(--el-color-primary-light-9); }
123
+ @media (max-width: 1100px) {
103
124
  .app-preset-layout { grid-template-columns: minmax(0, 1fr); }
104
- .app-preset-layout .app-preset-list { padding: 24px 4px 0 0; border-left: 0; border-top: 1px solid var(--ui-border); }
125
+ .app-preset-collection { padding: 24px 0 0; border-left: 0; border-top: 1px solid var(--ui-border); }
105
126
  }
106
127
  </style>
@@ -207,5 +207,14 @@ const openModelConfigGuide = () => {
207
207
  </template>
208
208
 
209
209
  <style scoped>
210
+ .config-midscene-card :deep(.el-card__header) { padding: 18px 24px; font-size: 16px; font-weight: 600; }
211
+ .config-midscene-card :deep(.el-card__body) { padding: 24px; background: var(--ui-surface); }
212
+ .config-midscene-card :deep(.el-form-item) { margin-bottom: 22px; }
213
+ .config-midscene-card :deep(.el-form-item__label) { margin-bottom: 8px; font-size: 13px; }
214
+ .config-midscene-card :deep(.el-input__wrapper), .config-midscene-card :deep(.el-select__wrapper) { min-height: 36px; }
210
215
  .config-model-input { width: 100%; }
216
+ @media (max-width: 1000px) {
217
+ .config-model-grid { grid-template-columns: minmax(0, 1fr); }
218
+ .config-model-grid > section + section { padding: 24px 0 0; border-left: 0; border-top: 1px solid var(--ui-border); }
219
+ }
211
220
  </style>
@@ -114,7 +114,7 @@ export function useModelConfig() {
114
114
  if (model.provider !== 'codex' && !model.apiKey.trim()) missing.push('API Key');
115
115
 
116
116
  if (!missing.length) return '';
117
- return `Midscene 模型配置不完整:缺少 ${missing.join('、')}。请在“参数配置 > Midscene配置 > Midscene 模型”中选择“使用 Codex”,或补齐自定义提供方后测试并保存。`;
117
+ return `Midscene 模型配置不完整:缺少 ${missing.join('、')}。请在“实验室 > Midscene > 参数配置 > Midscene 模型”中选择“使用 Codex”,或补齐自定义提供方后测试并保存。`;
118
118
  };
119
119
 
120
120
  const saveModelConfig = async () => {
@@ -1,9 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import { shallowRef } from 'vue';
3
3
  import BaseConfigPanel from '../components/config/BaseConfigPanel.vue';
4
- import MidsceneConfigPanel from '../components/config/MidsceneConfigPanel.vue';
5
4
  import AppiumConfigPanel from '../components/config/AppiumConfigPanel.vue';
6
- import type { MidsceneModelProvider } from '../config/midscene-model-presets';
7
5
  import type { AppPreset, ConfigForm } from '../types';
8
6
 
9
7
  defineProps<{
@@ -26,13 +24,11 @@ defineEmits<{
26
24
  editAppPreset: [app: AppPreset];
27
25
  deleteAppPreset: [id: string];
28
26
  cancelAppPresetEdit: [];
29
- updateMidsceneModelProvider: [provider: MidsceneModelProvider];
30
27
  }>();
31
28
 
32
29
  const tabs = [
33
30
  { name: 'basic', label: '基础配置' },
34
31
  { name: 'appium', label: 'Appium配置' },
35
- { name: 'midscene', label: 'Midscene配置' },
36
32
  ] as const;
37
33
  const activeTab = shallowRef<(typeof tabs)[number]['name']>('basic');
38
34
 
@@ -89,21 +85,6 @@ function handleTabKeydown(event: KeyboardEvent, index: number) {
89
85
  />
90
86
  </section>
91
87
 
92
- <section
93
- v-show="activeTab === 'midscene'"
94
- id="config-panel-midscene"
95
- role="tabpanel"
96
- aria-labelledby="config-tab-midscene"
97
- >
98
- <MidsceneConfigPanel
99
- :config-form="configForm"
100
- :testing-model-key="testingModelKey"
101
- :model-test-status="modelTestStatus"
102
- @test-model="$emit('testModel', $event)"
103
- @update-midscene-model-provider="$emit('updateMidsceneModelProvider', $event)"
104
- />
105
- </section>
106
-
107
88
  <section
108
89
  v-show="activeTab === 'appium'"
109
90
  id="config-panel-appium"
package/src/style.css CHANGED
@@ -3144,7 +3144,8 @@ body {
3144
3144
  font-weight: 600;
3145
3145
  }
3146
3146
 
3147
- .layout-menu .el-sub-menu .el-menu-item {
3147
+ .layout-menu .el-sub-menu .el-menu-item,
3148
+ .layout-menu .el-sub-menu .el-sub-menu > .el-sub-menu__title {
3148
3149
  min-width: 0;
3149
3150
  padding-left: 48px !important;
3150
3151
  }
@@ -3753,8 +3754,12 @@ body {
3753
3754
  display: flex;
3754
3755
  flex-direction: column;
3755
3756
  height: 86dvh;
3757
+ min-width: min(420px, calc(100vw - 32px));
3758
+ min-height: min(280px, calc(100dvh - 32px));
3759
+ max-width: calc(100vw - 32px);
3756
3760
  max-height: calc(100dvh - 32px);
3757
3761
  overflow: hidden;
3762
+ resize: both;
3758
3763
  padding: 0;
3759
3764
  border: 1px solid var(--ui-border);
3760
3765
  border-radius: var(--ui-radius);
package/src/types.ts CHANGED
@@ -5,7 +5,7 @@ import type { MidsceneModelProvider } from './config/midscene-model-presets';
5
5
  import type { AiRecognitionModel } from './appium-recorder/ai-recognition';
6
6
  import type { AiDeduplicationConfig } from './appium-recorder/ai-deduplication';
7
7
 
8
- export type MenuKey = 'analysis' | 'generator' | 'automation' | 'config' | 'appium' | 'artemis' | 'about';
8
+ export type MenuKey = 'analysis' | 'generator' | 'automation' | 'midscene-config' | 'config' | 'appium' | 'artemis' | 'about';
9
9
  export type GeneratorMode = 'ai' | 'manual';
10
10
 
11
11
  export type AppiumVersionInfo = {
@@ -373,6 +373,16 @@ AI 可能误判;问题验证通过也不代表运行时一定能判断。设
373
373
 
374
374
  导出包含连接关系的脚本时,会递归收集连接脚本到 ZIP;无连接时导出单个 JSON。启用回放录屏时,连接脚本可关联独立视频片段。
375
375
 
376
+ ### 39. 计时打点
377
+
378
+ **功能:** 为指定计时器开始计时、记录任意阶段或结束计时,按系统生成的计时器 ID 关联。此节点不查询设备、不判断等待条件。
379
+
380
+ **操作:** 在“流程控制 → 计时打点”中选择操作。开始节点填写计时器名称,系统自动生成只读计时器 ID;打点和结束节点通过“关联计时器”下拉选择具体的开始节点,选项显示名称、所属脚本、节点序号和 ID。名称仅用于显示,重命名不改变关联。日志中的阶段名称直接使用节点名称,无需单独设置时间点名称。例如:开始“登录耗时” → 点击登录 → 等待首页出现 → 结束节点选择该开始计时器。需要统计中间阶段时,在对应等待节点后添加“记录时间点”。
381
+
382
+ **结果与注意:** `TIMER:` 日志包含 `timerId`(系统生成的关联 ID)、`name`(计时器名称)、`run`(本次回放内该计时器第几次开始)、`point`(时间点)、`at`(UTC ISO 时间)、`elapsedMs`(距开始毫秒数)、`intervalMs`(距上次打点毫秒数)。基础报告保留节点输出;开启 AI 报告总结时,摘要内容取决于提示词,完整打点仍保留在原始日志。不额外生成业务专用统计表。以开始 → 首次正文 → 完成为例,首正文的 `elapsedMs` 是等待首字时间,完成的 `intervalMs` 是输出阶段耗时,完成的 `elapsedMs` 是总耗时,均包含等待与节点执行的观测延迟。
383
+
384
+ 同一回放中的主脚本和连接脚本通过 ID 关联计时器;同名而 ID 不同的计时器互不影响,每次回放重新初始化。未开始或已结束时打点会报错。循环再次执行同一个开始节点时,会重置该 ID 的计时器,`run` 自动增加;尚未结束时重新开始输出 `restarted: true`。复制包含开始节点的节点组或脚本时生成新 ID,并更新一起复制的关联;批量导入也同步更新跨脚本关联。单独复制打点或结束节点保留原有 ID,需改用其他计时器时重新选择。异常中止不自动补出完成时间,缺失的业务阶段应由日志明确说明。
385
+
376
386
  ## 六、旧脚本兼容节点
377
387
 
378
388
  以下类型仍可能出现在旧脚本中,但不是当前主操作菜单中的独立新增入口。