dsh-uitest 2.1.1 → 2.1.3

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.
@@ -3,7 +3,7 @@
3
3
  import fs from 'node:fs';
4
4
  import path from 'node:path';
5
5
  import process from 'node:process';
6
- import { Ab, sleep } from '../../fixtures/lib/ab.mjs';
6
+ import { Ab, sleep } from './ab.mjs';
7
7
  import { resolveUrl } from './config.mjs';
8
8
  import { ConfigError, StepError, ensureDir, slug, timeStamp, truncate } from './util.mjs';
9
9
  import { stopAgentBrowserSessions } from './agent-browser-cleanup.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-uitest",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "type": "module",
5
5
  "description": "Test Studio for DSH: import cases into natural-language tests, seed preconditions, run flow and Agent cases concurrently with agent-browser, archive evidence, write back by batch, and accumulate reusable flows and page knowledge.",
6
6
  "icon": "./icon.svg",
@@ -33,11 +33,19 @@
33
33
  "engines": {
34
34
  "node": ">=20"
35
35
  },
36
+ "scripts": {
37
+ "test": "node --test test/ studio/test/",
38
+ "preview": "node studio/preview/server.mjs"
39
+ },
36
40
  "dependencies": {
37
41
  "exceljs": "^4.4.0",
38
42
  "jszip": "^3.10.1",
39
43
  "playwright-core": "^1.56.0"
40
44
  },
45
+ "devDependencies": {
46
+ "react": "^18.3.1",
47
+ "react-dom": "^18.3.1"
48
+ },
41
49
  "dsh": {
42
50
  "bundle": {
43
51
  "patch": "./cordis.patch.yml"
@@ -40,17 +40,17 @@ flow 不是执行的前提。自然语言用例才是事实来源;flow 是执
40
40
 
41
41
  在测试工程目录下运行:
42
42
 
43
- node uitest/bin/studio.mjs import cases/新用例.md --project .
44
- node uitest/bin/studio.mjs cases --project . --mode agent
45
- node uitest/bin/studio.mjs plan --project . --case TC-FP001-01
46
- node uitest/bin/studio.mjs batch create --project . --case TC-FP001-01 --workers 3
47
- node uitest/bin/studio.mjs batch run --project . --id <batchId>
48
- node uitest/bin/studio.mjs batch status --project . --id <batchId>
49
- node uitest/bin/studio.mjs batch backfill --project . --id <batchId> --apply
50
- node uitest/bin/studio.mjs flows --project .
51
- node uitest/bin/studio.mjs knowledge --project .
52
- node uitest/bin/studio.mjs doctor --project .
53
- node uitest/bin/uitest.mjs agent-session knowledge --id <sessionId> --query "列表未加载" --project . --json
43
+ node bin/studio.mjs import cases/新用例.md --project .
44
+ node bin/studio.mjs cases --project . --mode agent
45
+ node bin/studio.mjs plan --project . --case TC-FP001-01
46
+ node bin/studio.mjs batch create --project . --case TC-FP001-01 --workers 3
47
+ node bin/studio.mjs batch run --project . --id <batchId>
48
+ node bin/studio.mjs batch status --project . --id <batchId>
49
+ node bin/studio.mjs batch backfill --project . --id <batchId> --apply
50
+ node bin/studio.mjs flows --project .
51
+ node bin/studio.mjs knowledge --project .
52
+ node bin/studio.mjs doctor --project .
53
+ node bin/uitest.mjs agent-session knowledge --id <sessionId> --query "列表未加载" --project . --json
54
54
 
55
55
  纯 CLI 只能跑 flow 泳道;Agent 泳道需要 DSH Host 的 subagents/agents 服务。没有活跃父 Agent 时,Host 会通过 sessionController 创建并复用「测试工作室 Agent 执行」会话。CLI 会把 Agent 用例标为阻塞,不会卡住其它用例。
56
56
 
@@ -1,6 +1,6 @@
1
1
  # 测试用例 xlsx 与结果库参考
2
2
 
3
- 本工具把 xlsx 测试用例工作簿当作**用例来源**,不要求工作簿由本工具生成;解析规则与字段别名集中定义在 `plugins/uitest/lib/xlsx.mjs`。
3
+ 本工具把 xlsx 测试用例工作簿当作**用例来源**,不要求工作簿由本工具生成;解析规则与字段别名集中定义在 `lib/xlsx.mjs`。
4
4
 
5
5
  ## 1. 工作簿结构假设
6
6
 
@@ -51,16 +51,16 @@
51
51
 
52
52
  ```bash
53
53
  # 摘要 + 前 N 条
54
- node plugins/uitest/bin/uitest.mjs cases --project <测试工程目录>
54
+ node bin/uitest.mjs cases --project <测试工程目录>
55
55
 
56
56
  # 按场景/关键字过滤,只看可自动化 A 类,限 20 条
57
- node plugins/uitest/bin/uitest.mjs cases --sheet 履约管理 --filter 偏差 --class A --limit 20 --detail
57
+ node bin/uitest.mjs cases --sheet 履约管理 --filter 偏差 --class A --limit 20 --detail
58
58
 
59
59
  # 精确看某条用例(序号或 TC 编号)
60
- node plugins/uitest/bin/uitest.mjs cases --id TC-FP012A-01 --detail
60
+ node bin/uitest.mjs cases --id TC-FP012A-01 --detail
61
61
 
62
62
  # 机器可读
63
- node plugins/uitest/bin/uitest.mjs cases --json --detail --limit 50
63
+ node bin/uitest.mjs cases --json --detail --limit 50
64
64
  ```
65
65
 
66
66
  `cases` 首次解析后缓存到 `.uitest/cases.json`,xlsx 文件修改时间/大小变化时自动失效重读。参数含义:
@@ -135,11 +135,11 @@ node plugins/uitest/bin/uitest.mjs cases --json --detail --limit 50
135
135
  在 `config.cases.xlsx` 之外,可把额外 xlsx(或目录)导入项目用例库;**不修改用户配置的 xlsx**。导入用例存 `<project>/.uitest/cases/imported.json`。
136
136
 
137
137
  ```bash
138
- node plugins/uitest/bin/uitest.mjs cases import extra.xlsx --project <工程目录>
139
- node plugins/uitest/bin/uitest.mjs cases import extra.xlsx --sheet 履约管理 --name "M006 回归用例" --project <工程目录>
140
- node plugins/uitest/bin/uitest.mjs cases import cases-dir --project <工程目录>
141
- node plugins/uitest/bin/uitest.mjs cases sources --project <工程目录>
142
- node plugins/uitest/bin/uitest.mjs cases remove --id <importId> --project <工程目录>
138
+ node bin/uitest.mjs cases import extra.xlsx --project <工程目录>
139
+ node bin/uitest.mjs cases import extra.xlsx --sheet 履约管理 --name "M006 回归用例" --project <工程目录>
140
+ node bin/uitest.mjs cases import cases-dir --project <工程目录>
141
+ node bin/uitest.mjs cases sources --project <工程目录>
142
+ node bin/uitest.mjs cases remove --id <importId> --project <工程目录>
143
143
  ```
144
144
 
145
145
  存储:
@@ -229,7 +229,7 @@ node plugins/uitest/bin/uitest.mjs cases remove --id <importId> --project <工
229
229
  写入命令:
230
230
 
231
231
  ```bash
232
- node plugins/uitest/bin/uitest.mjs result add \
232
+ node bin/uitest.mjs result add \
233
233
  --case TC-FP012A-01 \
234
234
  --status 失败 \
235
235
  --note "默认加载 169 条,最早 2026-07-03;默认 100 条/页" \
@@ -252,23 +252,23 @@ v1 的 `steps` 是字符串步骤(文档原文),不是 flow DSL。
252
252
 
253
253
  ```bash
254
254
  # 库
255
- node plugins/uitest/bin/uitest.mjs knowledge lib list --project <工程目录>
256
- node plugins/uitest/bin/uitest.mjs knowledge lib create "M006 订单管理系统" \
255
+ node ./bin/uitest.mjs knowledge lib list --project <工程目录>
256
+ node ./bin/uitest.mjs knowledge lib create "M006 订单管理系统" \
257
257
  [--id m006] [--description "..."] [--system "中谷海运 OMS"] --project <工程目录>
258
- node plugins/uitest/bin/uitest.mjs knowledge lib use m006-订单管理系统 --project <工程目录>
259
- node plugins/uitest/bin/uitest.mjs knowledge lib use --dir /data/knowledge/m006 --project <工程目录>
260
- node plugins/uitest/bin/uitest.mjs knowledge lib use --local --project <工程目录>
261
- node plugins/uitest/bin/uitest.mjs knowledge lib show m006-订单管理系统 --json --project <工程目录>
258
+ node ./bin/uitest.mjs knowledge lib use m006-订单管理系统 --project <工程目录>
259
+ node ./bin/uitest.mjs knowledge lib use --dir /data/knowledge/m006 --project <工程目录>
260
+ node ./bin/uitest.mjs knowledge lib use --local --project <工程目录>
261
+ node ./bin/uitest.mjs knowledge lib show m006-订单管理系统 --json --project <工程目录>
262
262
 
263
263
  # bundle 导出/导入
264
- node plugins/uitest/bin/uitest.mjs knowledge lib export [<idOrName>] \
264
+ node ./bin/uitest.mjs knowledge lib export [<idOrName>] \
265
265
  [--out /tmp/m006.json] --project <工程目录>
266
- node plugins/uitest/bin/uitest.mjs knowledge lib import /tmp/m006.json \
266
+ node ./bin/uitest.mjs knowledge lib import /tmp/m006.json \
267
267
  --name "M006 迁移副本" --project <工程目录>
268
- node plugins/uitest/bin/uitest.mjs knowledge lib import /tmp/m006.json \
268
+ node ./bin/uitest.mjs knowledge lib import /tmp/m006.json \
269
269
  --into m006-订单管理系统 --project <工程目录>
270
- node plugins/uitest/bin/uitest.mjs knowledge lib import /data/knowledge/m006 --project <工程目录>
271
- node plugins/uitest/bin/uitest.mjs knowledge lib import bundles-folder --project <工程目录>
270
+ node ./bin/uitest.mjs knowledge lib import /data/knowledge/m006 --project <工程目录>
271
+ node ./bin/uitest.mjs knowledge lib import bundles-folder --project <工程目录>
272
272
  ```
273
273
 
274
274
  CLI JSON 输出:
@@ -317,7 +317,7 @@ bundle 是 JSON(不是压缩包):
317
317
  ### 3.4 文档导入(Markdown/TXT)
318
318
 
319
319
  ```bash
320
- node plugins/uitest/bin/uitest.mjs knowledge import-doc docs/m006.md \
320
+ node ./bin/uitest.mjs knowledge import-doc docs/m006.md \
321
321
  [--name "M006 履约管理"] [--system "中谷海运 OMS"] [--into <idOrName>] --project <工程目录>
322
322
  ```
323
323
 
@@ -398,15 +398,15 @@ node plugins/uitest/bin/uitest.mjs knowledge import-doc docs/m006.md \
398
398
 
399
399
  ```bash
400
400
  # 选择文件夹(不存在会自动创建含父目录;--name 覆盖显示名)
401
- node plugins/uitest/bin/uitest.mjs knowledge lib use --dir /data/knowledge/m006 \
401
+ node ./bin/uitest.mjs knowledge lib use --dir /data/knowledge/m006 \
402
402
  --name "M006 订单管理系统" --project <工程目录>
403
403
 
404
404
  # 切回项目本地 / 共享库
405
- node plugins/uitest/bin/uitest.mjs knowledge lib use --local --project <工程目录>
406
- node plugins/uitest/bin/uitest.mjs knowledge lib use m006-订单管理系统 --project <工程目录>
405
+ node ./bin/uitest.mjs knowledge lib use --local --project <工程目录>
406
+ node ./bin/uitest.mjs knowledge lib use m006-订单管理系统 --project <工程目录>
407
407
 
408
408
  # bundle 导入到文件夹(自动建配置)
409
- node plugins/uitest/bin/uitest.mjs knowledge lib import /tmp/m006.json \
409
+ node ./bin/uitest.mjs knowledge lib import /tmp/m006.json \
410
410
  --into-dir /data/knowledge/m006 --project <工程目录>
411
411
  ```
412
412
 
@@ -556,10 +556,10 @@ CLI `knowledge lib use --dir` JSON:
556
556
 
557
557
  ```bash
558
558
  # 用 config.urls 名称(推荐)
559
- node plugins/uitest/bin/uitest.mjs learn page fulfillList --project <工程目录> --json
559
+ node ./bin/uitest.mjs learn page fulfillList --project <工程目录> --json
560
560
 
561
561
  # 用完整 URL;可指定 pageId/title 合并到既有页面
562
- node plugins/uitest/bin/uitest.mjs learn page "http://172.17.10.70:20600/ebdapp/..." \
562
+ node ./bin/uitest.mjs learn page "http://172.17.10.70:20600/ebdapp/..." \
563
563
  --id fulfill-list --title 履约单列表 --project <工程目录>
564
564
  ```
565
565
 
@@ -584,8 +584,8 @@ node plugins/uitest/bin/uitest.mjs learn page "http://172.17.10.70:20600/ebdapp/
584
584
  ### 4.2 从运行学习
585
585
 
586
586
  ```bash
587
- node plugins/uitest/bin/uitest.mjs learn from-run latest --project <工程目录> --json
588
- node plugins/uitest/bin/uitest.mjs learn from-run <run目录或label> --project <工程目录>
587
+ node ./bin/uitest.mjs learn from-run latest --project <工程目录> --json
588
+ node ./bin/uitest.mjs learn from-run <run目录或label> --project <工程目录>
589
589
  ```
590
590
 
591
591
  `latest` 取最近 `startedAt` 的 run;也接受绝对路径、相对 project 的路径、run 目录名、run label(模糊包含匹配)。
@@ -627,25 +627,25 @@ node plugins/uitest/bin/uitest.mjs learn from-run <run目录或label> --project
627
627
 
628
628
  ```bash
629
629
  # 预览:指定用例(--case 可重复;--ids 用逗号/空格分隔)
630
- node plugins/uitest/bin/uitest.mjs convert \
630
+ node ./bin/uitest.mjs convert \
631
631
  --case TC-FP012A-10 --case TC-FP012C-01 --project <工程目录> --json
632
632
 
633
633
  # 批量:默认选「未映射、class A」的前 N 条
634
- node plugins/uitest/bin/uitest.mjs convert --limit 10 --project <工程目录>
634
+ node ./bin/uitest.mjs convert --limit 10 --project <工程目录>
635
635
 
636
636
  # 换一份 xlsx / 工作表
637
- node plugins/uitest/bin/uitest.mjs convert --xlsx /path/to/other.xlsx --sheet 主表 \
637
+ node ./bin/uitest.mjs convert --xlsx /path/to/other.xlsx --sheet 主表 \
638
638
  --case <序号或TC> --project <工程目录>
639
639
 
640
640
  # 保存;同名 flow 已存在且需要覆盖时加 --force
641
- node plugins/uitest/bin/uitest.mjs convert --case TC-FP012A-10 --save --project <工程目录>
641
+ node ./bin/uitest.mjs convert --case TC-FP012A-10 --save --project <工程目录>
642
642
 
643
643
  # 已映射用例:综合最近 3 次 run + 提示重新生成(预览)
644
- node plugins/uitest/bin/uitest.mjs convert --case TC-FP012A-13 --regen \
644
+ node ./bin/uitest.mjs convert --case TC-FP012A-13 --regen \
645
645
  --hint "点击「更多」" --project <工程目录>
646
646
 
647
647
  # 覆盖原 flow(必须 --force)
648
- node plugins/uitest/bin/uitest.mjs convert --case TC-FP012A-13 --regen \
648
+ node ./bin/uitest.mjs convert --case TC-FP012A-13 --regen \
649
649
  --hint "上次空态断言失败,先等待 5 秒再人工确认" --save --force --project <工程目录>
650
650
  ```
651
651
 
@@ -799,7 +799,7 @@ node plugins/uitest/bin/uitest.mjs convert --case TC-FP012A-13 --regen \
799
799
  对已映射的 `auto-tc-fp012a-13`(TC-FP012A-13)执行:
800
800
 
801
801
  ```bash
802
- node plugins/uitest/bin/uitest.mjs convert --case TC-FP012A-13 --regen \
802
+ node ./bin/uitest.mjs convert --case TC-FP012A-13 --regen \
803
803
  --hint "上次空态断言失败,先等待 5 秒再人工确认空状态" --save --force --project <工程目录>
804
804
  ```
805
805
 
@@ -999,17 +999,17 @@ POST /api/uitest/feedback-review
999
999
 
1000
1000
  ```bash
1001
1001
  # 记录反馈(--run 相对 output.dir;--step 为 run.json 的步骤 id)
1002
- node plugins/uitest/bin/uitest.mjs feedback add --run runs/<name> --step s5 \
1002
+ node ./bin/uitest.mjs feedback add --run runs/<name> --step s5 \
1003
1003
  --verdict incorrect --case TC-FP012A-13 \
1004
1004
  --element-position "列表下方空状态区域" --note "先等待5秒再判断" \
1005
1005
  --screenshot screenshots/step-05-s5-failed.png --project <工程目录>
1006
1006
 
1007
1007
  # 关闭截图引用
1008
- node plugins/uitest/bin/uitest.mjs feedback add --run runs/<name> --step s5 \
1008
+ node ./bin/uitest.mjs feedback add --run runs/<name> --step s5 \
1009
1009
  --verdict unclear --no-use-screenshot --project <工程目录>
1010
1010
 
1011
1011
  # 查询
1012
- node plugins/uitest/bin/uitest.mjs feedback list --case TC-FP012A-13 --flow auto-tc-fp012a-13 \
1012
+ node ./bin/uitest.mjs feedback list --case TC-FP012A-13 --flow auto-tc-fp012a-13 \
1013
1013
  --run runs/<name> --limit 20 --project <工程目录>
1014
1014
  ```
1015
1015
 
@@ -1286,8 +1286,8 @@ knowledge-patch.json apply 时由 Host 从 result.knowledge 生成
1286
1286
  ### 13.6 CLI
1287
1287
 
1288
1288
  ```bash
1289
- node plugins/uitest/bin/uitest.mjs knowledge apply .uitest/agent-jobs/<jobId>/knowledge-patch.json --project <工程目录> --json
1290
- node plugins/uitest/bin/uitest.mjs flow validate flows/auto-tc-xxx.json --json
1289
+ node ./bin/uitest.mjs knowledge apply .uitest/agent-jobs/<jobId>/knowledge-patch.json --project <工程目录> --json
1290
+ node ./bin/uitest.mjs flow validate flows/auto-tc-xxx.json --json
1291
1291
  ```
1292
1292
 
1293
1293
  - `knowledge apply` 输出 `{ok,pages:{added,merged},recipes:{...},processes:{...},business:{...},target:{source,dir,name}}`;补丁非法 `KNOWLEDGE_PATCH_INVALID` 退出 1。
@@ -1,6 +1,6 @@
1
1
  # flow DSL 参考
2
2
 
3
- flow 是 JSON 文件(**不支持 YAML**,不支持注释),描述「打开页面 → 操作 → 断言」的步骤序列。执行器是 `plugins/uitest/lib/flow.mjs`,动作实现在 `plugins/uitest/lib/browser.mjs` 的 `performAction()`。
3
+ flow 是 JSON 文件(**不支持 YAML**,不支持注释),描述「打开页面 → 操作 → 断言」的步骤序列。执行器是 `./lib/flow.mjs`,动作实现在 `./lib/browser.mjs` 的 `performAction()`。
4
4
 
5
5
  ## 1. 文件结构
6
6
 
@@ -48,8 +48,8 @@
48
48
  `open`、`do ... shot` 把图写到 `<output.dir>/<shotsDir>/`(默认 `截图/`),文件名带时间戳,适合探索阶段留证:
49
49
 
50
50
  ```bash
51
- node plugins/uitest/bin/uitest.mjs open fulfillList --shot list-default --project <工程目录>
52
- node plugins/uitest/bin/uitest.mjs do shot --name detail-probe --project <工程目录>
51
+ node ./bin/uitest.mjs open fulfillList --shot list-default --project <工程目录>
52
+ node ./bin/uitest.mjs do shot --name detail-probe --project <工程目录>
53
53
  ```
54
54
 
55
55
  ### 2.3 结果证据登记
@@ -80,7 +80,7 @@ node plugins/uitest/bin/uitest.mjs do shot --name detail-probe --project <工程
80
80
  命令:
81
81
 
82
82
  ```bash
83
- node plugins/uitest/bin/uitest.mjs report --project <工程目录> --date 2026-11-09 --process
83
+ node ./bin/uitest.mjs report --project <工程目录> --date 2026-11-09 --process
84
84
  ```
85
85
 
86
86
  CSV 默认写 UTF-8 BOM(Excel 直接打开不乱码);需要无 BOM 时加 `--no-bom`,显式要求 BOM 时加 `--bom`。`result list` 可查看结果库最新记录(去重后)。
@@ -3,7 +3,7 @@
3
3
  先跑 `doctor`,再按症状定位。所有命令的公共参数是 `--project <测试工程目录>`(缺省当前目录),`--json` 输出机器可读结果。
4
4
 
5
5
  ```bash
6
- node plugins/uitest/bin/uitest.mjs doctor --project <工程目录>
6
+ node ./bin/uitest.mjs doctor --project <工程目录>
7
7
  ```
8
8
 
9
9
  `doctor` 检查项:Node ≥ 20、配置文件、playwright-core、chromium、baseUrl 可达性、登录账号/成功判据/登录态缓存、用例 xlsx、输出目录、守护进程状态。FAIL 项必须先修复。
@@ -23,7 +23,7 @@ node plugins/uitest/bin/uitest.mjs doctor --project <工程目录>
23
23
 
24
24
  ```bash
25
25
  export UITEST_PASSWORD='<密码>'
26
- node plugins/uitest/bin/uitest.mjs login --project <工程目录>
26
+ node ./bin/uitest.mjs login --project <工程目录>
27
27
  ```
28
28
 
29
29
  报错「缺少登录密码」即环境变量未设置。CLI 当前不提供 `--password`,不要把密码写进 `uitest.config.json` 或 flow。
@@ -51,12 +51,12 @@ node plugins/uitest/bin/uitest.mjs doctor --project <工程目录>
51
51
  2. **用一次性动作探页面**(自动拉起守护浏览器,无需先 `serve`):
52
52
 
53
53
  ```bash
54
- node plugins/uitest/bin/uitest.mjs do goto fulfillList --project <工程目录>
55
- node plugins/uitest/bin/uitest.mjs do text --project <工程目录>
56
- node plugins/uitest/bin/uitest.mjs do inputs --project <工程目录>
57
- node plugins/uitest/bin/uitest.mjs do links --project <工程目录>
58
- node plugins/uitest/bin/uitest.mjs do table --project <工程目录>
59
- node plugins/uitest/bin/uitest.mjs do shot --name probe --project <工程目录>
54
+ node ./bin/uitest.mjs do goto fulfillList --project <工程目录>
55
+ node ./bin/uitest.mjs do text --project <工程目录>
56
+ node ./bin/uitest.mjs do inputs --project <工程目录>
57
+ node ./bin/uitest.mjs do links --project <工程目录>
58
+ node ./bin/uitest.mjs do table --project <工程目录>
59
+ node ./bin/uitest.mjs do shot --name probe --project <工程目录>
60
60
  ```
61
61
 
62
62
  3. **回到 flow 改定位方式**:优先换文本/placeholder;必须用选择器时选带业务语义的属性,避免 `nth-child` 位置选择器。
@@ -173,7 +173,7 @@ daemon 信息写在 `.uitest/daemon.json`:`{pid, port, startedAt, projectDir,
173
173
  - shell 里传中文路径要加引号:
174
174
 
175
175
  ```bash
176
- node plugins/uitest/bin/uitest.mjs run flows/smoke-fulfill-list.json \
176
+ node ./bin/uitest.mjs run flows/smoke-fulfill-list.json \
177
177
  --project "<工程根>"
178
178
  ```
179
179
 
@@ -25,6 +25,7 @@ const HEADER_ALIASES = new Map([
25
25
  ['department', 'department'],
26
26
  ['业务片区', 'area'],
27
27
  ['片区', 'area'],
28
+ ['分部', 'area'],
28
29
  ['area', 'area'],
29
30
  ['兼职部门', 'partTime'],
30
31
  ['兼职', 'partTime'],
@@ -1,88 +0,0 @@
1
- <!doctype html>
2
- <html lang="zh-CN">
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <title>测试工作室 · 预览</title>
7
- <style>
8
- :root {
9
- --dsw-alias-bg-base: #f7f8fa;
10
- --dsw-alias-bg-layer-1: #ffffff;
11
- --dsw-alias-bg-layer-2: #f1f3f5;
12
- --dsw-alias-label-primary: #1f2329;
13
- --dsw-alias-label-secondary: #4e5969;
14
- --dsw-alias-label-tertiary: #86909c;
15
- --dsw-alias-label-primary-inverted: #ffffff;
16
- --dsw-alias-border-l1: #e5e6eb;
17
- --dsw-alias-button-primary-fill: #1f6feb;
18
- --dsw-alias-button-primary-hover: #1a5fc7;
19
- --dsw-alias-link: #1f6feb;
20
- --dsw-alias-state-success-primary: #12a150;
21
- --dsw-alias-state-error-primary: #d92d20;
22
- --dsw-alias-state-warn-primary: #d97706;
23
- --dsw-alias-state-business-primary: #7c3aed;
24
- --dsw-alias-interactive-bg-hover: #f2f3f5;
25
- --dsw-alias-interactive-bg-active: #e8f0fe;
26
- }
27
- body.dark {
28
- --dsw-alias-bg-base: #111318;
29
- --dsw-alias-bg-layer-1: #171a21;
30
- --dsw-alias-bg-layer-2: #1f232b;
31
- --dsw-alias-label-primary: #eef1f6;
32
- --dsw-alias-label-secondary: #aab2c0;
33
- --dsw-alias-label-tertiary: #737d8c;
34
- --dsw-alias-label-primary-inverted: #0b0d12;
35
- --dsw-alias-border-l1: #2a303a;
36
- --dsw-alias-button-primary-fill: #5b9dff;
37
- --dsw-alias-button-primary-hover: #7cb2ff;
38
- --dsw-alias-link: #6ea8ff;
39
- --dsw-alias-state-success-primary: #3ddc97;
40
- --dsw-alias-state-error-primary: #ff6b6b;
41
- --dsw-alias-state-warn-primary: #f4b740;
42
- --dsw-alias-state-business-primary: #b18cff;
43
- --dsw-alias-interactive-bg-hover: #20252e;
44
- --dsw-alias-interactive-bg-active: #1d2a44;
45
- }
46
- html, body, #root { height: 100%; margin: 0; }
47
- body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); }
48
- #root { display: flex; flex-direction: column; }
49
- .preview-toggle { position: fixed; right: 14px; bottom: 14px; z-index: 999; height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-secondary); font-size: 12px; cursor: pointer; }
50
- </style>
51
- </head>
52
- <body>
53
- <div id="root"></div>
54
- <button class="preview-toggle" onclick="document.body.classList.toggle('dark')">切换明暗</button>
55
- <script src="/node_modules/react/umd/react.development.js"></script>
56
- <script src="/node_modules/react-dom/umd/react-dom.development.js"></script>
57
- <script>
58
- window.__ModuleLoader__ = {
59
- load: function (definition) {
60
- window.__studioPlugin = definition.factory(function (name) {
61
- if (name === 'react') return window.React;
62
- throw new Error('unsupported module: ' + name);
63
- });
64
- }
65
- };
66
- </script>
67
- <script src="/client.js"></script>
68
- <script>
69
- (function () {
70
- var slots = {
71
- main: null,
72
- inject: function (_name, fn) { fn(); },
73
- register: function (spec, component) {
74
- if (spec && spec.name === 'main') slots.main = component;
75
- return function () {};
76
- }
77
- };
78
- var ctx = {
79
- effect: function (fn) { fn(); },
80
- locale: { register: function () {}, bind: function () { return function (key) { return key; }; } },
81
- slots: slots
82
- };
83
- window.__studioPlugin.apply(ctx);
84
- ReactDOM.createRoot(document.getElementById('root')).render(React.createElement(slots.main));
85
- })();
86
- </script>
87
- </body>
88
- </html>