Add Web FreeCAD manual matrix, capture harness and chapter 1 pilot
Co-Authored-By: Claude Code <noreply@anthropic.com>
57
web/manual/CONTINUATION.md
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
# Web FreeCAD 全功能初学者教案 · 接续点
|
||||||
|
|
||||||
|
更新:2026-11-13
|
||||||
|
计划:`/home/mes123456/.claude/plans/partitioned-puzzling-haven.md`
|
||||||
|
|
||||||
|
## 目标
|
||||||
|
|
||||||
|
单页中文 HTML 教案,覆盖 32 个模块;核心模块逐步精讲,专业模块 1–2 个工作流;
|
||||||
|
1492 条命令全部进附录;小缺口修 React/内核,大边界如实标注。
|
||||||
|
|
||||||
|
## 已完成(P0)
|
||||||
|
|
||||||
|
- `tools/manual/generate-features.mjs` → `manual/data/{manual-features,inventory-snapshot,coverage-audit}.json`
|
||||||
|
- 32/32 模块有章节;1602 条命令记录(1492 桌面 + 110 注册路由);
|
||||||
|
196 native handler 全部映射;312 精讲 / 1287 覆盖 / 3 边界。
|
||||||
|
- 边界已识别:`CAM_Adaptive`、`FEM_ResultShow`、`TechDraw_PageDefault`;
|
||||||
|
glTF/Cloud 等模块级边界待补入 gap ledger。
|
||||||
|
- `tools/manual/capture.mjs`:Playwright 动作 DSL(goto/wait/click/fill/select/press/
|
||||||
|
drag/eval/shot/save/assert),0 pageError/consoleError 门禁,截图 >5 KB,报告 JSON。
|
||||||
|
- `tools/manual/build-manual.mjs` + `template.html`:单页 HTML,侧栏/搜索/进度/灯箱/
|
||||||
|
命令索引/移动端抽屉;输出 `teaching/manual.html` + `manual-assets/`。
|
||||||
|
- 第 1 章样章:`content/ch01-ui.md` + `scenarios/ch01-ui.json`;
|
||||||
|
7 张真实截图(界面/Box/Placement/属性/视口/保存/总结)。
|
||||||
|
- 页面检查通过:1440×900 与 390×844 均 0 错误、0 破坏图片、0 横向溢出;
|
||||||
|
搜索 `Part_Box` 命中 4 条;命令索引 1602 行。
|
||||||
|
- `package.json` 增加 `manual:features` / `build:manual` / `check:manual`。
|
||||||
|
|
||||||
|
## 真实残余
|
||||||
|
|
||||||
|
- 只完成第 1 章;第 0、2–15 章正文与截图未开始。
|
||||||
|
- 边界只按精确命令匹配 3 条;需补 Fem/CAM/Cloud/Import 的模块级边界与桌面入口。
|
||||||
|
- 已验证状态(verified)尚未接入:当前 status 只有 detailed/overview/boundary;
|
||||||
|
截图断言通过后需回写矩阵与徽章。
|
||||||
|
- 第 1 章 `04-properties` 等图片为元素截图;后续章需统一全页 + 裁图规范。
|
||||||
|
- 命令索引 1602 行使 HTML 约 750 KB;后续章节图片外链,需持续监控体积。
|
||||||
|
- 未提交/推送;建议分支 `web-manual-20261113`。
|
||||||
|
|
||||||
|
## 下一步精确入口
|
||||||
|
|
||||||
|
1. 第 2 章:`content/ch02-part.md` + `scenarios/ch02-part.json`;
|
||||||
|
覆盖 Box/Cylinder/Boolean/Extrude/Revolve/Loft/Sweep/Fillet/Chamfer/Compound。
|
||||||
|
2. 边界补录:`generate-features.mjs` 的 `boundaries` 增加
|
||||||
|
Fem 原生对象、CAM 其余受限命令、Import_Gltf、Cloud、Material;
|
||||||
|
同步 `web/docs/current/web-freecad-manual-gaps.md`。
|
||||||
|
3. verified 回写:capture 成功后按 `chapter/workflow` 将截图与断言写回
|
||||||
|
`manual-features.json` 的 `screenshots[]` 与 `commands[].status`。
|
||||||
|
4. 每章完成:`npm run manual:features` → capture → `npm run build:manual` →
|
||||||
|
`npm run check:manual` → 更新本文件。
|
||||||
|
|
||||||
|
## 关键路径
|
||||||
|
|
||||||
|
- 应用:`http://127.0.0.1:5181/project.html?workbench=Part`
|
||||||
|
- 教学服务:`http://127.0.0.1:5190/manual.html`
|
||||||
|
- 矩阵输入:`web/public/api/workbench-command-matrix.json`、
|
||||||
|
`web/public/api/desktop-command-routes.json`、`web/src/module-registry.generated.ts`
|
||||||
|
- 截图:`web/manual/assets/<chapter>/<workflow>/`
|
||||||
|
- 证据:`web/manual/data/capture/<chapter>-<workflow>.json`
|
||||||
33
web/manual/README.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Web FreeCAD 全功能初学者图文教案
|
||||||
|
|
||||||
|
单页中文 HTML 教案:32 个模块、1492 条命令索引、核心模块分步截图、专业模块工作流与边界说明。
|
||||||
|
|
||||||
|
## 目录
|
||||||
|
|
||||||
|
- `content/*.md`:章节正文(front-matter: id/order/title/level)。
|
||||||
|
- `scenarios/*.json`:Playwright 动作脚本,用于截图与断言。
|
||||||
|
- `assets/<chapter>/<workflow>/`:真实界面截图。
|
||||||
|
- `data/manual-features.json`:命令覆盖矩阵。
|
||||||
|
- `data/inventory-snapshot.json`:输入文件 sha256。
|
||||||
|
- `data/coverage-audit.json`:模块/章节/状态计数。
|
||||||
|
- `data/capture/*.json`:每章截图与断言证据。
|
||||||
|
- `fixtures/`:capture 保存的 FCStd。
|
||||||
|
|
||||||
|
## 构建
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /home/mes123456/FreeCADWasmDev/working/FreeCAD/web
|
||||||
|
npm run manual:features # 生成命令矩阵
|
||||||
|
node tools/manual/capture.mjs --scenario manual/scenarios/ch01-ui.json
|
||||||
|
npm run build:manual # 生成 teaching/manual.html + manual-assets/
|
||||||
|
npm run check:manual # 桌面/移动、图片、搜索、命令索引
|
||||||
|
```
|
||||||
|
|
||||||
|
访问 `http://127.0.0.1:5190/manual.html`。
|
||||||
|
|
||||||
|
## 口径
|
||||||
|
|
||||||
|
- 命令状态:`detailed` 精讲、`overview` 覆盖、`boundary` 边界、`verified` 已验证。
|
||||||
|
- 大边界(TechDraw 跨 Worker、FEM 原生对象、CAM OpenCAMLib、glTF 原生导入导出、
|
||||||
|
Material/Cloud)只标注,不写成可用。
|
||||||
|
- 截图必须来自真实应用;0 pageError/consoleError、图片 >5 KB 才入库。
|
||||||
BIN
web/manual/assets/ch01/ui-and-document/01-interface.png
Normal file
|
After Width: | Height: | Size: 162 KiB |
BIN
web/manual/assets/ch01/ui-and-document/02-part-box.png
Normal file
|
After Width: | Height: | Size: 208 KiB |
BIN
web/manual/assets/ch01/ui-and-document/03-placement.png
Normal file
|
After Width: | Height: | Size: 213 KiB |
BIN
web/manual/assets/ch01/ui-and-document/04-properties.png
Normal file
|
After Width: | Height: | Size: 51 KiB |
BIN
web/manual/assets/ch01/ui-and-document/05-viewport.png
Normal file
|
After Width: | Height: | Size: 213 KiB |
BIN
web/manual/assets/ch01/ui-and-document/06-saved.png
Normal file
|
After Width: | Height: | Size: 281 KiB |
BIN
web/manual/assets/ch01/ui-and-document/07-summary.png
Normal file
|
After Width: | Height: | Size: 281 KiB |
94
web/manual/content/ch01-ui.md
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
---
|
||||||
|
id: ch01
|
||||||
|
order: 1
|
||||||
|
title: 界面、文档与视图
|
||||||
|
level: core
|
||||||
|
---
|
||||||
|
|
||||||
|
# 第 1 章 界面、文档与视图
|
||||||
|
|
||||||
|
## 学习目标
|
||||||
|
|
||||||
|
- 认清 Web FreeCAD 的菜单栏、工作台、对象树、属性面板和三维视口。
|
||||||
|
- 新建文档,创建一个可检查的实体,并在属性面板中修改尺寸、位置与颜色。
|
||||||
|
- 用鼠标旋转、缩放视口,最后把文档保存到 OPFS 并确认保存结果。
|
||||||
|
|
||||||
|
## 1.1 界面分区
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
从上到下、从左到右认识五个区域:
|
||||||
|
|
||||||
|
1. **应用菜单**:File、Edit、View、Part 等,所有命令的入口。
|
||||||
|
2. **工作台选择器**:当前是 `Part`,切换后菜单和工具按钮会变化。
|
||||||
|
3. **对象树**:显示文档中的对象、标签和内部名称。
|
||||||
|
4. **属性面板**:显示选中对象的 View、Placement、Data 与几何统计。
|
||||||
|
5. **三维视口**:显示模型;左键旋转,滚轮缩放,右键平移。
|
||||||
|
|
||||||
|
## 1.2 新建文档
|
||||||
|
|
||||||
|
打开 `File → 新建 Document`。新建后对象树为空,状态栏会显示当前活动文档名。
|
||||||
|
本课程一律使用毫米作为长度单位;属性面板里的 `Length/Width/Height` 都按毫米填写。
|
||||||
|
|
||||||
|
## 1.3 创建第一个对象
|
||||||
|
|
||||||
|
打开 `Part → Primitives → Box`,在任务面板填入:
|
||||||
|
|
||||||
|
| 参数 | 值 |
|
||||||
|
|---|---|
|
||||||
|
| Length | 60 mm |
|
||||||
|
| Width | 40 mm |
|
||||||
|
| Height | 20 mm |
|
||||||
|
|
||||||
|
点“应用尺寸并重算”,再把对象标签改成 `ManualCube`。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 1.4 属性面板与 Placement
|
||||||
|
|
||||||
|
选中对象后,属性面板分为:
|
||||||
|
|
||||||
|
- **View**:Label、Color、Visibility。
|
||||||
|
- **Placement**:Position(X/Y/Z)与旋转轴/角度。
|
||||||
|
- **Data**:Length、Width、Height 等参数。
|
||||||
|
- **Geometry/Volume/Bounds**:面数、三角面数、体积和包围盒。
|
||||||
|
|
||||||
|
把 Position 设为 `(10, 20, 30)`,点“应用位置与旋转”。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 1.5 视口导航
|
||||||
|
|
||||||
|
在视口里按住左键拖动可以旋转;滚轮缩放;右键拖动平移。
|
||||||
|
右上角的视图菜单可以切换等轴测、前视、顶视等标准视角。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 1.6 保存到 OPFS
|
||||||
|
|
||||||
|
打开右侧文件工具,点“保存 FCStd 到 OPFS”。状态栏出现
|
||||||
|
`Saved <文件名>.FCStd to OPFS` 即表示保存成功。Web 版默认写 OPFS,
|
||||||
|
只有用户点“下载”时才会落到本地磁盘。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 自检
|
||||||
|
|
||||||
|
- [ ] 对象树只有 `ManualCube` 一个对象。
|
||||||
|
- [ ] Length/Width/Height 分别为 60/40/20 mm。
|
||||||
|
- [ ] Position 为 (10, 20, 30) mm。
|
||||||
|
- [ ] 视口可以旋转和缩放。
|
||||||
|
- [ ] 状态栏显示保存成功。
|
||||||
|
|
||||||
|
## 常见错误
|
||||||
|
|
||||||
|
1. 把米直接填进毫米输入框,模型小一千倍。
|
||||||
|
2. 修改尺寸后没有点“应用尺寸并重算”,对象仍是默认 10 mm。
|
||||||
|
3. 只改了显示颜色但没有触发应用,保存后颜色丢失。
|
||||||
|
4. 保存后没有看状态栏,误以为文件已经下载到本地。
|
||||||
|
|
||||||
|
## 练习
|
||||||
|
|
||||||
|
1. 把 Box 改成 100 × 50 × 25 mm,观察体积和包围盒变化。
|
||||||
|
2. 再创建一个 Cylinder,比较两者在对象树中的命名规则。
|
||||||
|
3. 保存后刷新页面,从 OPFS 重新打开文档,确认对象仍在。
|
||||||
269
web/manual/data/capture/ch01-ui-and-document.json
Normal file
@@ -0,0 +1,269 @@
|
|||||||
|
{
|
||||||
|
"schema": "freecad-web-manual/capture/v1",
|
||||||
|
"generatedAt": "2026-11-13T03:08:26.848Z",
|
||||||
|
"chapter": "ch01",
|
||||||
|
"workflow": "ui-and-document",
|
||||||
|
"scenario": "manual/scenarios/ch01-ui.json",
|
||||||
|
"origin": "http://127.0.0.1:5181",
|
||||||
|
"ok": true,
|
||||||
|
"trace": [
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:08.382Z",
|
||||||
|
"action": "goto",
|
||||||
|
"url": "/project.html?workbench=Part"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:10.169Z",
|
||||||
|
"action": "waitFor",
|
||||||
|
"selector": "select[aria-label=\"Workbench\"]",
|
||||||
|
"text": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:11.729Z",
|
||||||
|
"action": "click",
|
||||||
|
"selector": "nav[aria-label=\"Application menus\"] details"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:11.813Z",
|
||||||
|
"action": "click",
|
||||||
|
"selector": "新建 Document"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:14.020Z",
|
||||||
|
"action": "eval"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:14.253Z",
|
||||||
|
"action": "shot",
|
||||||
|
"name": "01-interface",
|
||||||
|
"bytes": 165728
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:14.323Z",
|
||||||
|
"action": "click",
|
||||||
|
"selector": ".part-menu > summary"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:14.770Z",
|
||||||
|
"action": "click",
|
||||||
|
"selector": "details.part-submenu"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:15.119Z",
|
||||||
|
"action": "click",
|
||||||
|
"selector": "button[data-command=\"Part_Box\"]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:16.353Z",
|
||||||
|
"action": "click",
|
||||||
|
"selector": ".fc-tree-text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:16.773Z",
|
||||||
|
"action": "fill",
|
||||||
|
"selector": "input[aria-label=\"Length\"]",
|
||||||
|
"value": 60
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:16.807Z",
|
||||||
|
"action": "fill",
|
||||||
|
"selector": "input[aria-label=\"Width\"]",
|
||||||
|
"value": 40
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:16.832Z",
|
||||||
|
"action": "fill",
|
||||||
|
"selector": "input[aria-label=\"Height\"]",
|
||||||
|
"value": 20
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:16.937Z",
|
||||||
|
"action": "click",
|
||||||
|
"selector": "应用尺寸并重算"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:18.510Z",
|
||||||
|
"action": "click",
|
||||||
|
"selector": "Close task / Cancel"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:18.552Z",
|
||||||
|
"action": "click",
|
||||||
|
"selector": ".fc-tree-text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:18.867Z",
|
||||||
|
"action": "fill",
|
||||||
|
"selector": "input[aria-label=\"Object Label\"]",
|
||||||
|
"value": "ManualCube"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:18.878Z",
|
||||||
|
"action": "press",
|
||||||
|
"key": "Enter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:20.050Z",
|
||||||
|
"action": "shot",
|
||||||
|
"name": "02-part-box",
|
||||||
|
"bytes": 212824
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:20.179Z",
|
||||||
|
"action": "click",
|
||||||
|
"selector": "Position"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:20.591Z",
|
||||||
|
"action": "fill",
|
||||||
|
"selector": "input[aria-label=\"Position X\"]",
|
||||||
|
"value": 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:20.610Z",
|
||||||
|
"action": "fill",
|
||||||
|
"selector": "input[aria-label=\"Position Y\"]",
|
||||||
|
"value": 20
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:20.647Z",
|
||||||
|
"action": "fill",
|
||||||
|
"selector": "input[aria-label=\"Position Z\"]",
|
||||||
|
"value": 30
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:20.734Z",
|
||||||
|
"action": "click",
|
||||||
|
"selector": "应用位置与旋转"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:21.979Z",
|
||||||
|
"action": "click",
|
||||||
|
"selector": "Close task / Cancel"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:22.236Z",
|
||||||
|
"action": "shot",
|
||||||
|
"name": "03-placement",
|
||||||
|
"bytes": 218043
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:22.296Z",
|
||||||
|
"action": "click",
|
||||||
|
"selector": ".fc-tree-text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:22.608Z",
|
||||||
|
"action": "fill",
|
||||||
|
"selector": "input[aria-label=\"Object Color\"]",
|
||||||
|
"value": "#4a90d9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:22.612Z",
|
||||||
|
"action": "eval"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:23.443Z",
|
||||||
|
"action": "shot",
|
||||||
|
"name": "04-properties",
|
||||||
|
"bytes": 52634
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:24.180Z",
|
||||||
|
"action": "drag",
|
||||||
|
"selector": "[aria-label=\"Imported native 3D view\"]",
|
||||||
|
"dx": -120,
|
||||||
|
"dy": -40
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:24.383Z",
|
||||||
|
"action": "shot",
|
||||||
|
"name": "05-viewport",
|
||||||
|
"bytes": 218276
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:25.595Z",
|
||||||
|
"action": "save",
|
||||||
|
"name": "web_project_document_3.FCStd",
|
||||||
|
"bytes": 2569,
|
||||||
|
"status": "Saved web_project_document_3.FCStd to OPFS (2569 bytes)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:26.399Z",
|
||||||
|
"action": "assertVisible",
|
||||||
|
"selector": ".fc-tree-text:has-text(\"ManualCube\")"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:26.618Z",
|
||||||
|
"action": "shot",
|
||||||
|
"name": "06-saved",
|
||||||
|
"bytes": 287402
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"at": "2026-11-13T03:08:26.848Z",
|
||||||
|
"action": "shot",
|
||||||
|
"name": "07-summary",
|
||||||
|
"bytes": 287402
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"shots": [
|
||||||
|
{
|
||||||
|
"id": "ch01/ui-and-document/01-interface",
|
||||||
|
"file": "manual/assets/ch01/ui-and-document/01-interface.png",
|
||||||
|
"bytes": 165728,
|
||||||
|
"sha256": "a6b2b7b8ea4149233a9054b2d96a8a289f83366fef5c270dd8e0642245a3337d",
|
||||||
|
"fullPage": true,
|
||||||
|
"selector": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "ch01/ui-and-document/02-part-box",
|
||||||
|
"file": "manual/assets/ch01/ui-and-document/02-part-box.png",
|
||||||
|
"bytes": 212824,
|
||||||
|
"sha256": "541ad0dcac5096d09124c6ab51f3d84db3b3c3901ae56a67ac970fee2a324281",
|
||||||
|
"fullPage": true,
|
||||||
|
"selector": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "ch01/ui-and-document/03-placement",
|
||||||
|
"file": "manual/assets/ch01/ui-and-document/03-placement.png",
|
||||||
|
"bytes": 218043,
|
||||||
|
"sha256": "3ca3b5cf7c0466e57ae353edee4a19a0ecd90537d36098e43a6fc26cfe86c4c4",
|
||||||
|
"fullPage": true,
|
||||||
|
"selector": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "ch01/ui-and-document/04-properties",
|
||||||
|
"file": "manual/assets/ch01/ui-and-document/04-properties.png",
|
||||||
|
"bytes": 52634,
|
||||||
|
"sha256": "564f2483692cc4e7bd746394498c7a592d6b3dcaa70e0ab2ee6a2c4a173120ab",
|
||||||
|
"fullPage": false,
|
||||||
|
"selector": "aside.properties"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "ch01/ui-and-document/05-viewport",
|
||||||
|
"file": "manual/assets/ch01/ui-and-document/05-viewport.png",
|
||||||
|
"bytes": 218276,
|
||||||
|
"sha256": "89b20c2f977311a6e1206637fb04400810b9a9191f9152e5e0bef4525d589061",
|
||||||
|
"fullPage": true,
|
||||||
|
"selector": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "ch01/ui-and-document/06-saved",
|
||||||
|
"file": "manual/assets/ch01/ui-and-document/06-saved.png",
|
||||||
|
"bytes": 287402,
|
||||||
|
"sha256": "5276720fee5bc4d9f1c9583a35f18ca3cf092cf853dfc43517d118d305835ffa",
|
||||||
|
"fullPage": true,
|
||||||
|
"selector": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "ch01/ui-and-document/07-summary",
|
||||||
|
"file": "manual/assets/ch01/ui-and-document/07-summary.png",
|
||||||
|
"bytes": 287402,
|
||||||
|
"sha256": "5276720fee5bc4d9f1c9583a35f18ca3cf092cf853dfc43517d118d305835ffa",
|
||||||
|
"fullPage": true,
|
||||||
|
"selector": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"pageErrors": [],
|
||||||
|
"consoleErrors": []
|
||||||
|
}
|
||||||
35
web/manual/data/coverage-audit.json
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"schema": "freecad-web-manual/coverage/v1",
|
||||||
|
"generatedAt": "2026-11-13T03:05:48.506Z",
|
||||||
|
"modules": 32,
|
||||||
|
"unknownModules": [],
|
||||||
|
"nativeHandlers": 196,
|
||||||
|
"nativeMapped": 196,
|
||||||
|
"desktopRecords": 1492,
|
||||||
|
"registryCommands": 306,
|
||||||
|
"routes": 1296,
|
||||||
|
"byChapter": {
|
||||||
|
"ch00": 237,
|
||||||
|
"ch01": 0,
|
||||||
|
"ch02": 93,
|
||||||
|
"ch03": 141,
|
||||||
|
"ch04": 96,
|
||||||
|
"ch05": 39,
|
||||||
|
"ch06": 51,
|
||||||
|
"ch07": 9,
|
||||||
|
"ch08": 104,
|
||||||
|
"ch09": 208,
|
||||||
|
"ch10": 139,
|
||||||
|
"ch11": 145,
|
||||||
|
"ch12": 105,
|
||||||
|
"ch13": 235,
|
||||||
|
"ch14": 0,
|
||||||
|
"ch15": 0
|
||||||
|
},
|
||||||
|
"byStatus": {
|
||||||
|
"detailed": 312,
|
||||||
|
"overview": 1287,
|
||||||
|
"boundary": 3
|
||||||
|
},
|
||||||
|
"ok": true
|
||||||
|
}
|
||||||
30
web/manual/data/inventory-snapshot.json
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"schema": "freecad-web-manual/inventory/v1",
|
||||||
|
"generatedAt": "2026-11-13T03:05:48.516Z",
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"path": "public/api/workbench-command-matrix.json",
|
||||||
|
"sha256": "0f467b45c2ed0105bc3f9d58a6149f18a6dc65dd86a93fc6b4f53cd1a39cfe5c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "public/api/desktop-command-routes.json",
|
||||||
|
"sha256": "6b21e4b2a7b06f5516433771bba06d61d1e7f3daa0e9a68c83aad6e000b4a25a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "src/module-registry.generated.ts",
|
||||||
|
"sha256": "359b2c34821e8b0696e584d2c840bc21e339a6dabe177746378748cd9bdb1af1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "teaching/data/features.json",
|
||||||
|
"sha256": "b9b9ef9fdb612d6a6e92b828be3749be92096b68892bf762e16c33f622571c35"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "teaching/data/cases.json",
|
||||||
|
"sha256": "d871f200bfd504f44bdf87216e6e09eb4ae2a2971fc66434542367e2cb0e35fc"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "docs/current/freecad-official-case-ledger.json",
|
||||||
|
"sha256": "d03239f0faef109020f99b3ae2a4d0bd1ef8396b656f52278942914fa57d8bc7"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
29698
web/manual/data/manual-features.json
Normal file
42
web/manual/data/page-check.json
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"schema": "freecad-web-manual/page-check/v1",
|
||||||
|
"generatedAt": "2026-11-13T03:11:58.755Z",
|
||||||
|
"url": "http://127.0.0.1:5190/manual.html",
|
||||||
|
"viewports": [
|
||||||
|
{
|
||||||
|
"viewport": {
|
||||||
|
"width": 1440,
|
||||||
|
"height": 900
|
||||||
|
},
|
||||||
|
"status": 200,
|
||||||
|
"errors": [],
|
||||||
|
"failed": [],
|
||||||
|
"searchHits": 4,
|
||||||
|
"chapters": 1,
|
||||||
|
"sections": 10,
|
||||||
|
"images": 6,
|
||||||
|
"brokenImages": [],
|
||||||
|
"commandRows": 1602,
|
||||||
|
"overflow": 0,
|
||||||
|
"searchSize": 1613
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"viewport": {
|
||||||
|
"width": 390,
|
||||||
|
"height": 844
|
||||||
|
},
|
||||||
|
"status": 200,
|
||||||
|
"errors": [],
|
||||||
|
"failed": [],
|
||||||
|
"searchHits": 4,
|
||||||
|
"chapters": 1,
|
||||||
|
"sections": 10,
|
||||||
|
"images": 6,
|
||||||
|
"brokenImages": [],
|
||||||
|
"commandRows": 1602,
|
||||||
|
"overflow": 0,
|
||||||
|
"searchSize": 1613
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ok": true
|
||||||
|
}
|
||||||
BIN
web/manual/fixtures/ch01-ui-and-document.FCStd
Normal file
58
web/manual/scenarios/ch01-ui.json
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
{
|
||||||
|
"schema": "freecad-web-manual/scenario/v1",
|
||||||
|
"chapter": "ch01",
|
||||||
|
"workflow": "ui-and-document",
|
||||||
|
"title": "界面、文档、对象树、属性、视图与保存",
|
||||||
|
"actions": [
|
||||||
|
{ "type": "goto", "url": "/project.html?workbench=Part" },
|
||||||
|
{ "type": "waitFor", "selector": "select[aria-label=\"Workbench\"]" },
|
||||||
|
{ "type": "wait", "ms": 1200 },
|
||||||
|
{ "type": "click", "selector": "nav[aria-label=\"Application menus\"] details", "hasText": "File", "target": ":scope > summary" },
|
||||||
|
{ "type": "click", "role": "button", "name": "新建 Document", "exact": true },
|
||||||
|
{ "type": "wait", "ms": 2200 },
|
||||||
|
{ "type": "eval", "script": "for (const d of document.querySelectorAll('nav[aria-label=\"Application menus\"] details[open]')) d.open = false" },
|
||||||
|
{ "type": "shot", "name": "01-interface", "fullPage": true },
|
||||||
|
{ "type": "click", "selector": ".part-menu > summary", "timeout": 30000 },
|
||||||
|
{ "type": "wait", "ms": 300 },
|
||||||
|
{ "type": "click", "selector": "details.part-submenu", "hasText": "Primitives", "target": ":scope > summary" },
|
||||||
|
{ "type": "wait", "ms": 300 },
|
||||||
|
{ "type": "click", "selector": "button[data-command=\"Part_Box\"]" },
|
||||||
|
{ "type": "wait", "ms": 1200 },
|
||||||
|
{ "type": "click", "selector": ".fc-tree-text", "hasText": "Cube" },
|
||||||
|
{ "type": "wait", "ms": 400 },
|
||||||
|
{ "type": "fill", "selector": "input[aria-label=\"Length\"]", "value": 60 },
|
||||||
|
{ "type": "fill", "selector": "input[aria-label=\"Width\"]", "value": 40 },
|
||||||
|
{ "type": "fill", "selector": "input[aria-label=\"Height\"]", "value": 20 },
|
||||||
|
{ "type": "click", "role": "button", "name": "应用尺寸并重算", "exact": true },
|
||||||
|
{ "type": "wait", "ms": 1500 },
|
||||||
|
{ "type": "click", "role": "button", "name": "Close task / Cancel", "exact": true },
|
||||||
|
{ "type": "click", "selector": ".fc-tree-text", "hasText": "Cube" },
|
||||||
|
{ "type": "wait", "ms": 300 },
|
||||||
|
{ "type": "fill", "selector": "input[aria-label=\"Object Label\"]", "value": "ManualCube" },
|
||||||
|
{ "type": "press", "key": "Enter" },
|
||||||
|
{ "type": "wait", "ms": 800 },
|
||||||
|
{ "type": "shot", "name": "02-part-box", "fullPage": true },
|
||||||
|
{ "type": "click", "role": "button", "name": "Position", "exact": true },
|
||||||
|
{ "type": "wait", "ms": 400 },
|
||||||
|
{ "type": "fill", "selector": "input[aria-label=\"Position X\"]", "value": 10 },
|
||||||
|
{ "type": "fill", "selector": "input[aria-label=\"Position Y\"]", "value": 20 },
|
||||||
|
{ "type": "fill", "selector": "input[aria-label=\"Position Z\"]", "value": 30 },
|
||||||
|
{ "type": "click", "role": "button", "name": "应用位置与旋转", "exact": true },
|
||||||
|
{ "type": "wait", "ms": 1200 },
|
||||||
|
{ "type": "click", "role": "button", "name": "Close task / Cancel", "exact": true },
|
||||||
|
{ "type": "shot", "name": "03-placement", "fullPage": true },
|
||||||
|
{ "type": "click", "selector": ".fc-tree-text", "hasText": "ManualCube" },
|
||||||
|
{ "type": "wait", "ms": 300 },
|
||||||
|
{ "type": "fill", "selector": "input[aria-label=\"Object Color\"]", "value": "#4a90d9" },
|
||||||
|
{ "type": "eval", "script": "document.querySelector('input[aria-label=\"Object Color\"]')?.dispatchEvent(new Event('change', { bubbles: true }))" },
|
||||||
|
{ "type": "wait", "ms": 600 },
|
||||||
|
{ "type": "shot", "name": "04-properties", "selector": "aside.properties" },
|
||||||
|
{ "type": "drag", "selector": "[aria-label=\"Imported native 3D view\"]", "dx": -120, "dy": -40 },
|
||||||
|
{ "type": "shot", "name": "05-viewport", "fullPage": true },
|
||||||
|
{ "type": "save" },
|
||||||
|
{ "type": "wait", "ms": 800 },
|
||||||
|
{ "type": "assertVisible", "selector": ".fc-tree-text:has-text(\"ManualCube\")" },
|
||||||
|
{ "type": "shot", "name": "06-saved", "fullPage": true },
|
||||||
|
{ "type": "shot", "name": "07-summary", "fullPage": true }
|
||||||
|
]
|
||||||
|
}
|
||||||
71
web/package.json
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
{
|
||||||
|
"name": "freecad-1-2-web",
|
||||||
|
"private": true,
|
||||||
|
"version": "0.1.0",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"format:coverage": "node ../tools/run_p6_format_coverage_gate.mjs",
|
||||||
|
"full-parity:gate": "python3 ../tools/run_full_parity_gate.py",
|
||||||
|
"material:tier1-gate": "node ../tools/run_p6_material_python_family_gate.mjs",
|
||||||
|
"sync-show-python-family-fixture": "node ../tools/sync_show_python_family_fixture.mjs",
|
||||||
|
"sync-api-index": "python3 ../tools/generate_python_api_runtime_index.py",
|
||||||
|
"sync-object-index": "python3 ../tools/generate_object_runtime_index.py",
|
||||||
|
"sync-format-index": "python3 ../tools/generate_format_runtime_index.py",
|
||||||
|
"sync-module-registry": "python3 ../tools/generate_web_module_registry.py",
|
||||||
|
"sync-release-manifest": "python3 ../tools/generate_web_release_manifest.py",
|
||||||
|
"sync-part-tier2-adapter": "python3 ../tools/generate_part_tier2_adapter_manifest.py",
|
||||||
|
"sync-partdesign-tier2-adapter": "python3 ../tools/generate_python_family_adapter_manifest.py PartDesign tier-2-pure --output docs/p6/partdesign-tier2-adapter-manifest.json",
|
||||||
|
"sync-sketcher-tier2-adapter": "python3 ../tools/generate_python_family_adapter_manifest.py Sketcher tier-2-pure --output docs/p6/sketcher-tier2-adapter-manifest.json",
|
||||||
|
"sync-techdraw-tier2-adapter": "python3 ../tools/generate_python_family_adapter_manifest.py TechDraw tier-2-pure --output docs/p6/techdraw-tier2-adapter-manifest.json",
|
||||||
|
"sync-import-tier2-adapter": "python3 ../tools/generate_python_family_adapter_manifest.py Import tier-2-pure --output docs/p6/import-tier2-adapter-manifest.json",
|
||||||
|
"sync-mesh-tier2-adapter": "python3 ../tools/generate_python_family_adapter_manifest.py Mesh tier-2-pure --output docs/p6/mesh-tier2-adapter-manifest.json",
|
||||||
|
"sync-material-tier1-adapter": "python3 ../tools/generate_python_family_adapter_manifest.py Material tier-1-readonly --output docs/p6/material-tier1-readonly-adapter-manifest.json",
|
||||||
|
"sync-tier2-remainder": "python3 ../tools/generate_remaining_tier2_adapter_manifests.py",
|
||||||
|
"sync-tier3-stateful": "python3 ../tools/generate_tier3_stateful_adapter_manifest.py",
|
||||||
|
"sync-viewprovider-index": "python3 ../tools/generate_viewprovider_runtime_index.py",
|
||||||
|
"sync-property-index": "python3 ../tools/generate_property_runtime_index.py",
|
||||||
|
"sync-geometry-index": "python3 ../tools/generate_geometry_runtime_index.py",
|
||||||
|
"sync-document-graph-index": "python3 ../tools/generate_document_graph_runtime_index.py",
|
||||||
|
"sync-capability-index": "python3 ../tools/generate_capability_runtime_index.py",
|
||||||
|
"sync-tier1-readonly": "python3 ../tools/generate_tier1_readonly_adapter_manifest.py",
|
||||||
|
"sync-tier4-restricted": "python3 ../tools/generate_tier4_restricted_manifest.py",
|
||||||
|
"sync-api-adapter-fill": "python3 ../tools/generate_api_adapter_fill_manifest.py",
|
||||||
|
"sync-format-extensions": "python3 ../tools/generate_format_extension_manifest.py",
|
||||||
|
"sync-kernel": "node tools/sync-assets.mjs",
|
||||||
|
"build:wasm-modules": "python3 ../tools/build_web_module_artifacts.py",
|
||||||
|
"sync:wasm-manifest": "node tools/sync-assets.mjs",
|
||||||
|
"check:geometry-boundary": "node tools/audit-geometry-boundary.mjs",
|
||||||
|
"resume:official": "node ../tools/auto-resume-official-case.mjs --json",
|
||||||
|
"checkpoint:official": "node ../tools/official-case-checkpoint.mjs",
|
||||||
|
"check:official-continuation": "node ../tools/auto-resume-official-case.mjs --json && node ../tools/check-official-case-continuation.mjs --json",
|
||||||
|
"manual:features": "node tools/manual/generate-features.mjs",
|
||||||
|
"build:manual": "node tools/manual/build-manual.mjs",
|
||||||
|
"check:manual": "node tools/manual/check-page.mjs",
|
||||||
|
"prebuild": "npm run sync-show-python-family-fixture && npm run check:geometry-boundary",
|
||||||
|
"dev": "npm run sync-api-index && npm run sync-object-index && npm run sync-format-index && npm run sync-module-registry && npm run sync-part-tier2-adapter && npm run sync-partdesign-tier2-adapter && npm run sync-sketcher-tier2-adapter && npm run sync-techdraw-tier2-adapter && npm run sync-import-tier2-adapter && npm run sync-mesh-tier2-adapter && npm run sync-material-tier1-adapter && npm run sync-tier2-remainder && npm run sync-tier3-stateful && npm run sync-viewprovider-index && npm run sync-property-index && npm run sync-geometry-index && npm run sync-document-graph-index && npm run sync-capability-index && npm run sync-tier1-readonly && npm run sync-tier4-restricted && npm run sync-api-adapter-fill && npm run sync-format-extensions && npm run sync-kernel && npm run sync-release-manifest && vite --host 0.0.0.0",
|
||||||
|
"build": "npm run sync-api-index && npm run sync-object-index && npm run sync-format-index && npm run sync-module-registry && npm run sync-part-tier2-adapter && npm run sync-partdesign-tier2-adapter && npm run sync-sketcher-tier2-adapter && npm run sync-techdraw-tier2-adapter && npm run sync-import-tier2-adapter && npm run sync-mesh-tier2-adapter && npm run sync-material-tier1-adapter && npm run sync-tier2-remainder && npm run sync-tier3-stateful && npm run sync-viewprovider-index && npm run sync-property-index && npm run sync-geometry-index && npm run sync-document-graph-index && npm run sync-capability-index && npm run sync-tier1-readonly && npm run sync-tier4-restricted && npm run sync-api-adapter-fill && npm run sync-format-extensions && npm run sync-kernel && npm run sync-release-manifest && tsc --noEmit && vite build",
|
||||||
|
"preview": "vite preview --host 0.0.0.0",
|
||||||
|
"build-and-publish": "node tools/build-and-publish.mjs"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/react": "^18.3.12",
|
||||||
|
"@types/react-dom": "^18.3.1",
|
||||||
|
"lucide": "1.32.0",
|
||||||
|
"marked": "15.0.12",
|
||||||
|
"react": "^18.3.1",
|
||||||
|
"react-arborist": "^4.0.1",
|
||||||
|
"react-dnd": "^16.0.1",
|
||||||
|
"react-dnd-html5-backend": "^16.0.1",
|
||||||
|
"react-dom": "^18.3.1",
|
||||||
|
"react-window": "^1.8.11",
|
||||||
|
"redux": "^5.0.1",
|
||||||
|
"three": "0.185.1",
|
||||||
|
"ws": "^8.22.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/three": "0.185.0",
|
||||||
|
"playwright": "^1.64.1",
|
||||||
|
"typescript": "5.9.3",
|
||||||
|
"vite": "8.2.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
web/teaching/manual-assets/ch01/ui-and-document/01-interface.png
Normal file
|
After Width: | Height: | Size: 162 KiB |
BIN
web/teaching/manual-assets/ch01/ui-and-document/02-part-box.png
Normal file
|
After Width: | Height: | Size: 208 KiB |
BIN
web/teaching/manual-assets/ch01/ui-and-document/03-placement.png
Normal file
|
After Width: | Height: | Size: 213 KiB |
|
After Width: | Height: | Size: 51 KiB |
BIN
web/teaching/manual-assets/ch01/ui-and-document/05-viewport.png
Normal file
|
After Width: | Height: | Size: 213 KiB |
BIN
web/teaching/manual-assets/ch01/ui-and-document/06-saved.png
Normal file
|
After Width: | Height: | Size: 281 KiB |
BIN
web/teaching/manual-assets/ch01/ui-and-document/07-summary.png
Normal file
|
After Width: | Height: | Size: 281 KiB |
5078
web/teaching/manual.html
Normal file
137
web/tools/manual/build-manual.mjs
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
// Builds the single-page Chinese manual from web/manual/content/*.md plus the
|
||||||
|
// feature matrix, and copies screenshots to web/teaching/manual-assets/.
|
||||||
|
import fs from "node:fs";
|
||||||
|
import path from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
import { marked } from "marked";
|
||||||
|
|
||||||
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
const webRoot = path.resolve(here, "../..");
|
||||||
|
const contentDir = path.join(webRoot, "manual", "content");
|
||||||
|
const assetsDir = path.join(webRoot, "manual", "assets");
|
||||||
|
const outFile = path.join(webRoot, "teaching", "manual.html");
|
||||||
|
const outAssets = path.join(webRoot, "teaching", "manual-assets");
|
||||||
|
const featuresPath = path.join(webRoot, "manual", "data", "manual-features.json");
|
||||||
|
|
||||||
|
const features = JSON.parse(fs.readFileSync(featuresPath, "utf8"));
|
||||||
|
const chapterTitle = new Map(features.chapters.map(chapter => [chapter.id, chapter.title]));
|
||||||
|
const esc = value => String(value ?? "").replace(/&/g, "&").replace(/</g, "<")
|
||||||
|
.replace(/>/g, ">").replace(/"/g, """);
|
||||||
|
|
||||||
|
const parseFrontMatter = text => {
|
||||||
|
const match = /^---\n([\s\S]*?)\n---\n([\s\S]*)$/.exec(text);
|
||||||
|
if (!match) return { meta: {}, body: text };
|
||||||
|
const meta = {};
|
||||||
|
for (const line of match[1].split("\n")) {
|
||||||
|
const [key, ...rest] = line.split(":");
|
||||||
|
if (key) meta[key.trim()] = rest.join(":").trim();
|
||||||
|
}
|
||||||
|
return { meta, body: match[2] };
|
||||||
|
};
|
||||||
|
|
||||||
|
const slug = text => String(text).toLowerCase().trim()
|
||||||
|
.replace(/[`*_]/g, "").replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-+|-+$/g, "").slice(0, 60);
|
||||||
|
|
||||||
|
const chapters = fs.readdirSync(contentDir).filter(name => name.endsWith(".md")).map(name => {
|
||||||
|
const text = fs.readFileSync(path.join(contentDir, name), "utf8");
|
||||||
|
const { meta, body } = parseFrontMatter(text);
|
||||||
|
return { file: name, meta, body, id: meta.id ?? name.replace(/\.md$/, ""), order: Number(meta.order ?? 999) };
|
||||||
|
}).sort((a, b) => a.order - b.order);
|
||||||
|
|
||||||
|
const sidebar = [];
|
||||||
|
const searchIndex = [];
|
||||||
|
const sections = [];
|
||||||
|
for (const chapter of chapters) {
|
||||||
|
const html = marked.parse(chapter.body);
|
||||||
|
const withIds = html.replace(/<h([12])>([\s\S]*?)<\/h\1>/g, (whole, level, inner) => {
|
||||||
|
const text = inner.replace(/<[^>]+>/g, "").trim();
|
||||||
|
const id = Number(level) === 1 ? chapter.id : `${chapter.id}-${slug(text)}`;
|
||||||
|
return `<h${level} id="${esc(id)}">${inner}</h${level}>`;
|
||||||
|
}).replace(/<img([^>]*?)>/g, (whole, attrs) => /loading=/.test(attrs) ? whole : `<img loading="lazy"${attrs}>`);
|
||||||
|
sections.push({ ...chapter, html: withIds });
|
||||||
|
|
||||||
|
const h2s = [...chapter.body.matchAll(/^## (.+)$/gm)].map(match => {
|
||||||
|
const title = match[1].replace(/[`*_]/g, "").trim();
|
||||||
|
return { id: `${chapter.id}-${slug(title)}`, title };
|
||||||
|
});
|
||||||
|
sidebar.push({ id: chapter.id, title: chapter.meta.title ?? chapter.id, sections: h2s,
|
||||||
|
done: chapter.meta.level !== "appendix" });
|
||||||
|
const parts = chapter.body.split(/^## /m);
|
||||||
|
const chapterMeta = { title: chapter.meta.title ?? chapter.id, chapter: chapter.meta.title ?? chapter.id };
|
||||||
|
if (parts[0]) searchIndex.push({ id: chapter.id, title: chapterMeta.title, chapter: chapterMeta.chapter,
|
||||||
|
text: parts[0].replace(/[#>*`|\-]/g, " ").replace(/\s+/g, " ").slice(0, 400), commands: [] });
|
||||||
|
for (const part of parts.slice(1)) {
|
||||||
|
const [titleLine, ...rest] = part.split("\n");
|
||||||
|
const title = titleLine.replace(/[`*_]/g, "").trim();
|
||||||
|
searchIndex.push({ id: `${chapter.id}-${slug(title)}`, title, chapter: chapterMeta.title,
|
||||||
|
text: rest.join(" ").replace(/[#>*`|\-]/g, " ").replace(/\s+/g, " ").slice(0, 400), commands: [] });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const sidebarHtml = `<ol>${sidebar.map(chapter => `<li>
|
||||||
|
<div class="chapter"><input type="checkbox" data-progress="${esc(chapter.id)}" aria-label="完成 ${esc(chapter.title)}" /><a href="#${esc(chapter.id)}">${esc(chapter.title)}</a></div>
|
||||||
|
${chapter.sections.map(section => `<a class="sec" href="#${esc(section.id)}">${esc(section.title)}</a>`).join("")}
|
||||||
|
</li>`).join("")}</ol>`;
|
||||||
|
|
||||||
|
const statusLabel = { detailed: "精讲", overview: "覆盖", boundary: "边界", verified: "已验证", "fix-needed": "待修" };
|
||||||
|
const moduleOptions = [...new Set(features.commands.map(item => item.module))].sort()
|
||||||
|
.map(module => `<option value="${esc(module)}">${esc(module)}</option>`).join("");
|
||||||
|
const indexRows = features.commands.map(item => {
|
||||||
|
const anchor = `cmd-${slug(item.module)}-${slug(item.command)}`;
|
||||||
|
return `<tr id="${esc(anchor)}" data-module="${esc(item.module)}" data-status="${esc(item.status)}">
|
||||||
|
<td>${esc(item.module)}</td><td><code>${esc(item.command)}</code></td><td>${esc(item.kind)}</td>
|
||||||
|
<td><span class="badge ${esc(item.status)}">${esc(statusLabel[item.status] ?? item.status)}</span></td>
|
||||||
|
<td>${esc(chapterTitle.get(item.chapterId) ?? item.chapterId ?? "-")}</td><td>${esc(item.ledgerCaseId ?? "-")}</td></tr>`;
|
||||||
|
}).join("");
|
||||||
|
const searchCommands = features.commands.map(item => ({
|
||||||
|
id: `cmd-${slug(item.module)}-${slug(item.command)}`,
|
||||||
|
title: `${item.module} · ${item.command}`,
|
||||||
|
chapter: chapterTitle.get(item.chapterId) ?? "附录",
|
||||||
|
text: `${item.disposition} ${item.kind} ${statusLabel[item.status] ?? item.status}`,
|
||||||
|
commands: [item.command, item.module],
|
||||||
|
}));
|
||||||
|
searchIndex.push(...searchCommands);
|
||||||
|
const commandIndex = `<section id="command-index-section"><h1 id="ch15">附录:命令索引</h1>
|
||||||
|
<p>共 ${features.commands.length} 条命令记录,其中 ${features.stats.nativeHandlers} 条 native handler。
|
||||||
|
状态含义:精讲 = 有分步教程;覆盖 = 有工作流/命令说明;边界 = 当前 Web 端受限并注明原因。</p>
|
||||||
|
<div class="index-controls">
|
||||||
|
<select id="filter-module" aria-label="按模块筛选"><option value="">全部模块</option>${moduleOptions}</select>
|
||||||
|
<select id="filter-status" aria-label="按状态筛选"><option value="">全部状态</option><option value="detailed">精讲</option><option value="overview">覆盖</option><option value="boundary">边界</option></select>
|
||||||
|
<input id="filter-command" type="search" placeholder="筛选命令…" aria-label="筛选命令" />
|
||||||
|
</div>
|
||||||
|
<div class="table-scroll"><table id="command-index"><thead><tr><th>模块</th><th>命令</th><th>类型</th><th>状态</th><th>章节</th><th>案例</th></tr></thead><tbody>${indexRows}</tbody></table></div></section>`;
|
||||||
|
|
||||||
|
let content = sections.map(chapter => chapter.html).join("\n");
|
||||||
|
const pager = chapters.map((chapter, index) => {
|
||||||
|
const prev = chapters[index - 1]; const next = chapters[index + 1];
|
||||||
|
return `${prev ? `<a href="#${esc(prev.id)}">← ${esc(prev.meta.title ?? prev.id)}</a>` : "<span></span>"}
|
||||||
|
${next ? `<a href="#${esc(next.id)}">${esc(next.meta.title ?? next.id)} →</a>` : "<span></span>"}`;
|
||||||
|
}).join("\n");
|
||||||
|
content = content.replace(/<h1 id="ch15">/, `<div class="pager">${pager}</div><h1 id="ch15">`);
|
||||||
|
|
||||||
|
// Validate referenced screenshots before writing.
|
||||||
|
const missing = [];
|
||||||
|
for (const chapter of chapters) {
|
||||||
|
for (const match of chapter.body.matchAll(/!\[[^\]]*\]\(([^)]+)\)/g)) {
|
||||||
|
const src = match[1];
|
||||||
|
if (!src.startsWith("./manual-assets/")) continue;
|
||||||
|
const file = path.join(assetsDir, src.replace("./manual-assets/", ""));
|
||||||
|
if (!fs.existsSync(file)) missing.push(src);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (missing.length) throw new Error(`missing screenshots: ${missing.slice(0, 5).join(", ")}`);
|
||||||
|
|
||||||
|
fs.mkdirSync(outAssets, { recursive: true });
|
||||||
|
fs.cpSync(assetsDir, outAssets, { recursive: true });
|
||||||
|
const template = fs.readFileSync(path.join(here, "template.html"), "utf8");
|
||||||
|
const html = template
|
||||||
|
.replaceAll("{{TITLE}}", "Web FreeCAD 全功能初学者图文教案")
|
||||||
|
.replace("{{SIDEBAR}}", sidebarHtml)
|
||||||
|
.replace("{{CONTENT}}", content)
|
||||||
|
.replace("{{COMMAND_INDEX}}", commandIndex)
|
||||||
|
.replace("{{SEARCH_INDEX}}", JSON.stringify(searchIndex).replace(/</g, "\\u003c"))
|
||||||
|
.replace("{{COMMAND_COUNT}}", String(features.commands.length));
|
||||||
|
fs.writeFileSync(outFile, html);
|
||||||
|
console.log(JSON.stringify({ ok: true, outFile, chapters: chapters.length, sections: sections.length,
|
||||||
|
commands: features.commands.length, searchEntries: searchIndex.length, bytes: fs.statSync(outFile).size }));
|
||||||
177
web/tools/manual/capture.mjs
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
// Runs a manual scenario in the real app, asserts UI state and captures
|
||||||
|
// full-page / element screenshots. Usage:
|
||||||
|
// node capture.mjs --scenario ../../manual/scenarios/ch01-ui.json [--headed]
|
||||||
|
import fs from "node:fs";
|
||||||
|
import path from "node:path";
|
||||||
|
import { createHash } from "node:crypto";
|
||||||
|
import { createRequire } from "node:module";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
import { listOpfsFiles, readOpfsFile } from "../carrier-course/lib/opfs.mjs";
|
||||||
|
|
||||||
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
const webRoot = path.resolve(here, "../..");
|
||||||
|
const require = createRequire(path.join(webRoot, "package.json"));
|
||||||
|
const { chromium } = require("playwright");
|
||||||
|
|
||||||
|
const args = process.argv.slice(2);
|
||||||
|
const option = (name, fallback = "") => {
|
||||||
|
const index = args.indexOf(name);
|
||||||
|
return index < 0 ? fallback : args[index + 1] ?? fallback;
|
||||||
|
};
|
||||||
|
const scenarioPath = path.resolve(option("--scenario"));
|
||||||
|
if (!fs.existsSync(scenarioPath)) throw new Error(`missing scenario ${scenarioPath}`);
|
||||||
|
const scenario = JSON.parse(fs.readFileSync(scenarioPath, "utf8"));
|
||||||
|
const origin = option("--origin", "http://127.0.0.1:5181");
|
||||||
|
const headed = args.includes("--headed");
|
||||||
|
const chapter = scenario.chapter;
|
||||||
|
const workflow = scenario.workflow;
|
||||||
|
const shotDir = path.join(webRoot, "manual", "assets", chapter, workflow);
|
||||||
|
const reportDir = path.join(webRoot, "manual", "data", "capture");
|
||||||
|
fs.mkdirSync(shotDir, { recursive: true });
|
||||||
|
fs.mkdirSync(reportDir, { recursive: true });
|
||||||
|
|
||||||
|
const sha256 = file => createHash("sha256").update(fs.readFileSync(file)).digest("hex");
|
||||||
|
|
||||||
|
async function runOnce() {
|
||||||
|
const browser = await chromium.launch({
|
||||||
|
executablePath: "/usr/bin/google-chrome",
|
||||||
|
headless: !headed,
|
||||||
|
args: ["--no-sandbox", "--disable-dev-shm-usage", "--enable-unsafe-swiftshader",
|
||||||
|
"--use-gl=angle", "--use-angle=swiftshader", "--window-size=1600,900"],
|
||||||
|
});
|
||||||
|
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
|
||||||
|
const pageErrors = [];
|
||||||
|
const consoleErrors = [];
|
||||||
|
page.on("pageerror", error => pageErrors.push(String(error)));
|
||||||
|
page.on("console", message => { if (message.type() === "error") consoleErrors.push(message.text().slice(0, 300)); });
|
||||||
|
const trace = [];
|
||||||
|
const shots = [];
|
||||||
|
|
||||||
|
const record = entry => trace.push({ at: new Date().toISOString(), ...entry });
|
||||||
|
const click = async action => {
|
||||||
|
let locator;
|
||||||
|
if (action.role) locator = page.getByRole(action.role, { name: action.name, exact: action.exact });
|
||||||
|
else {
|
||||||
|
locator = page.locator(action.selector);
|
||||||
|
if (action.hasText) locator = locator.filter({ hasText: action.hasText });
|
||||||
|
if (action.target) locator = locator.locator(action.target);
|
||||||
|
}
|
||||||
|
if (action.nth !== undefined) locator = locator.nth(action.nth);
|
||||||
|
else if (!action.all) locator = locator.first();
|
||||||
|
if (action.all) {
|
||||||
|
const count = await locator.count();
|
||||||
|
for (let index = 0; index < count; index++) await locator.nth(index).click();
|
||||||
|
} else await locator.click({ timeout: action.timeout ?? 30000 });
|
||||||
|
};
|
||||||
|
const shot = async action => {
|
||||||
|
const file = path.join(shotDir, `${action.name}.png`);
|
||||||
|
if (action.selector) {
|
||||||
|
const target = page.locator(action.selector).first();
|
||||||
|
await target.waitFor({ state: "visible", timeout: 30000 });
|
||||||
|
await target.screenshot({ path: file });
|
||||||
|
} else {
|
||||||
|
await page.screenshot({ path: file, fullPage: Boolean(action.fullPage) });
|
||||||
|
}
|
||||||
|
const stat = fs.statSync(file);
|
||||||
|
if (stat.size < 5 * 1024) throw new Error(`screenshot too small: ${file}`);
|
||||||
|
shots.push({ id: `${chapter}/${workflow}/${action.name}`, file: path.relative(webRoot, file),
|
||||||
|
bytes: stat.size, sha256: sha256(file), fullPage: Boolean(action.fullPage), selector: action.selector ?? null });
|
||||||
|
record({ action: "shot", name: action.name, bytes: stat.size });
|
||||||
|
};
|
||||||
|
const save = async action => {
|
||||||
|
await page.evaluate(() => { const details = document.querySelector(".file-tools"); if (details) details.open = true; });
|
||||||
|
await page.waitForTimeout(400);
|
||||||
|
const before = await listOpfsFiles(page);
|
||||||
|
await page.locator('button:has-text("保存 FCStd 到 OPFS")').first().click();
|
||||||
|
let after = before; let status = "";
|
||||||
|
for (let attempt = 0; attempt < 40; attempt++) {
|
||||||
|
await page.waitForTimeout(750);
|
||||||
|
after = await listOpfsFiles(page);
|
||||||
|
status = await page.locator("p.status").first().textContent().catch(() => "");
|
||||||
|
if (after.some(name => !before.includes(name) && /\.FCStd$/i.test(name)) || /Saved\s+\S+\.FCStd\s+to OPFS/i.test(status ?? "")) break;
|
||||||
|
}
|
||||||
|
const match = /Saved\s+(\S+\.FCStd)\s+to OPFS/i.exec(status ?? "");
|
||||||
|
const name = match?.[1] ?? after.find(item => !before.includes(item) && /\.FCStd$/i.test(item));
|
||||||
|
if (!name) throw new Error(`save produced no FCStd; status=${status}`);
|
||||||
|
const bytes = (await readOpfsFile(page, name)).bytes;
|
||||||
|
const fixture = path.join(webRoot, "manual", "fixtures", `${chapter}-${workflow}.FCStd`);
|
||||||
|
fs.mkdirSync(path.dirname(fixture), { recursive: true });
|
||||||
|
fs.writeFileSync(fixture, Buffer.from(bytes));
|
||||||
|
record({ action: "save", name, bytes: bytes.length, status });
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (const action of scenario.actions) {
|
||||||
|
switch (action.type) {
|
||||||
|
case "goto":
|
||||||
|
await page.goto(`${origin}${action.url}`, { waitUntil: "domcontentloaded", timeout: 120000 });
|
||||||
|
record({ action: "goto", url: action.url });
|
||||||
|
break;
|
||||||
|
case "waitFor":
|
||||||
|
if (action.selector) await page.waitForSelector(action.selector, { timeout: action.timeout ?? 120000 });
|
||||||
|
if (action.text) await page.getByText(action.text, { exact: action.exact ?? false }).first()
|
||||||
|
.waitFor({ state: "visible", timeout: action.timeout ?? 120000 });
|
||||||
|
record({ action: "waitFor", selector: action.selector ?? null, text: action.text ?? null });
|
||||||
|
break;
|
||||||
|
case "click": await click(action); record({ action: "click", selector: action.selector ?? action.name }); break;
|
||||||
|
case "fill":
|
||||||
|
await page.locator(action.selector).first().fill(String(action.value));
|
||||||
|
record({ action: "fill", selector: action.selector, value: action.value });
|
||||||
|
break;
|
||||||
|
case "select":
|
||||||
|
await page.locator(action.selector).first().selectOption(action.label ? { label: action.label } : action.value);
|
||||||
|
record({ action: "select", selector: action.selector, label: action.label ?? action.value });
|
||||||
|
break;
|
||||||
|
case "press": await page.keyboard.press(action.key); record({ action: "press", key: action.key }); break;
|
||||||
|
case "drag": {
|
||||||
|
const box = await page.locator(action.selector).first().boundingBox();
|
||||||
|
if (!box) throw new Error(`drag target missing: ${action.selector}`);
|
||||||
|
const x = box.x + box.width / 2; const y = box.y + box.height / 2;
|
||||||
|
await page.mouse.move(x, y); await page.mouse.down();
|
||||||
|
await page.mouse.move(x + (action.dx ?? 0), y + (action.dy ?? 0), { steps: 18 });
|
||||||
|
await page.mouse.up(); await page.waitForTimeout(400);
|
||||||
|
record({ action: "drag", selector: action.selector, dx: action.dx, dy: action.dy });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "eval":
|
||||||
|
await page.evaluate(action.script);
|
||||||
|
record({ action: "eval" });
|
||||||
|
break;
|
||||||
|
case "shot": await shot(action); break;
|
||||||
|
case "save": await save(action); break;
|
||||||
|
case "assertText": {
|
||||||
|
const text = await page.locator(action.selector).first().textContent();
|
||||||
|
if (!String(text ?? "").includes(action.contains)) throw new Error(`assertText failed: ${action.selector} ${text}`);
|
||||||
|
record({ action: "assertText", selector: action.selector, contains: action.contains });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "assertVisible":
|
||||||
|
await page.locator(action.selector).first().waitFor({ state: "visible", timeout: 30000 });
|
||||||
|
record({ action: "assertVisible", selector: action.selector });
|
||||||
|
break;
|
||||||
|
case "wait": await page.waitForTimeout(action.ms ?? 500); break;
|
||||||
|
default: throw new Error(`unknown action ${action.type}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pageErrors.length || consoleErrors.length)
|
||||||
|
throw new Error(`page errors: ${JSON.stringify({ pageErrors, consoleErrors })}`);
|
||||||
|
const report = {
|
||||||
|
schema: "freecad-web-manual/capture/v1", generatedAt: new Date().toISOString(),
|
||||||
|
chapter, workflow, scenario: path.relative(webRoot, scenarioPath), origin,
|
||||||
|
ok: true, trace, shots, pageErrors, consoleErrors,
|
||||||
|
};
|
||||||
|
fs.writeFileSync(path.join(reportDir, `${chapter}-${workflow}.json`), `${JSON.stringify(report, null, 2)}\n`);
|
||||||
|
return report;
|
||||||
|
} finally {
|
||||||
|
await browser.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const report = await runOnce();
|
||||||
|
console.log(JSON.stringify({ ok: true, chapter, workflow, shots: report.shots.length }));
|
||||||
|
} catch (error) {
|
||||||
|
console.error(JSON.stringify({ ok: false, error: String(error?.stack ?? error) }));
|
||||||
|
process.exitCode = 1;
|
||||||
|
}
|
||||||
50
web/tools/manual/check-page.mjs
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
// Checks the generated manual on desktop and mobile, including images, search
|
||||||
|
// and the command index. Writes manual/data/page-check.json.
|
||||||
|
import fs from "node:fs";
|
||||||
|
import path from "node:path";
|
||||||
|
import { createRequire } from "node:module";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
const webRoot = path.resolve(here, "../..");
|
||||||
|
const require = createRequire(path.join(webRoot, "package.json"));
|
||||||
|
const { chromium } = require("playwright");
|
||||||
|
const url = process.env.MANUAL_URL || "http://127.0.0.1:5190/manual.html";
|
||||||
|
const browser = await chromium.launch({ executablePath: "/usr/bin/google-chrome", headless: true,
|
||||||
|
args: ["--no-sandbox", "--enable-unsafe-swiftshader", "--use-gl=angle", "--use-angle=swiftshader"] });
|
||||||
|
const report = { schema: "freecad-web-manual/page-check/v1", generatedAt: new Date().toISOString(), url, viewports: [] };
|
||||||
|
for (const viewport of [{ width: 1440, height: 900 }, { width: 390, height: 844 }]) {
|
||||||
|
const page = await browser.newPage({ viewport });
|
||||||
|
const errors = []; const failed = [];
|
||||||
|
page.on("pageerror", error => errors.push(String(error)));
|
||||||
|
page.on("console", message => { if (message.type() === "error") errors.push(message.text().slice(0, 200)); });
|
||||||
|
page.on("response", response => { if (response.status() >= 400) failed.push(`${response.status()} ${response.url()}`); });
|
||||||
|
const response = await page.goto(url, { waitUntil: "load", timeout: 120000 });
|
||||||
|
await page.waitForTimeout(800);
|
||||||
|
const metrics = await page.evaluate(() => {
|
||||||
|
const images = [...document.images];
|
||||||
|
return {
|
||||||
|
chapters: document.querySelectorAll('nav.sidebar .chapter').length,
|
||||||
|
sections: document.querySelectorAll('main h2[id]').length,
|
||||||
|
images: images.length,
|
||||||
|
brokenImages: images.filter(image => image.src && (!image.complete || image.naturalWidth === 0)).map(image => image.src),
|
||||||
|
commandRows: document.querySelectorAll('#command-index tbody tr').length,
|
||||||
|
overflow: document.documentElement.scrollWidth - document.documentElement.clientWidth,
|
||||||
|
searchSize: SEARCH_INDEX.length,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
await page.locator('#search').fill('Part_Box');
|
||||||
|
await page.waitForTimeout(300);
|
||||||
|
const searchHits = await page.locator('#search-results a').count();
|
||||||
|
if (viewport.width === 1440) await page.screenshot({ path: path.join(webRoot, "teaching", "manual.png"), fullPage: false });
|
||||||
|
report.viewports.push({ viewport, status: response?.status(), errors, failed, searchHits, ...metrics });
|
||||||
|
await page.close();
|
||||||
|
}
|
||||||
|
await browser.close();
|
||||||
|
report.ok = report.viewports.every(item => item.status === 200 && item.errors.length === 0
|
||||||
|
&& item.failed.length === 0 && item.brokenImages.length === 0 && item.overflow === 0
|
||||||
|
&& item.commandRows > 1500 && item.searchHits > 0);
|
||||||
|
fs.writeFileSync(path.join(webRoot, "manual", "data", "page-check.json"), `${JSON.stringify(report, null, 2)}\n`);
|
||||||
|
console.log(JSON.stringify(report));
|
||||||
|
process.exitCode = report.ok ? 0 : 1;
|
||||||
195
web/tools/manual/generate-features.mjs
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
// Builds the authoritative manual feature matrix from the command matrix,
|
||||||
|
// desktop routes, registry, UI catalogs and the official case ledger.
|
||||||
|
// Fails when a module has no chapter or a native handler is unmapped.
|
||||||
|
import fs from "node:fs";
|
||||||
|
import path from "node:path";
|
||||||
|
import { createHash } from "node:crypto";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
const webRoot = path.resolve(here, "../..");
|
||||||
|
const outDir = path.join(webRoot, "manual", "data");
|
||||||
|
fs.mkdirSync(outDir, { recursive: true });
|
||||||
|
|
||||||
|
const readJson = file => JSON.parse(fs.readFileSync(file, "utf8"));
|
||||||
|
const sha256 = file => createHash("sha256").update(fs.readFileSync(file)).digest("hex");
|
||||||
|
|
||||||
|
const matrixPath = path.join(webRoot, "public/api/workbench-command-matrix.json");
|
||||||
|
const routesPath = path.join(webRoot, "public/api/desktop-command-routes.json");
|
||||||
|
const registryPath = path.join(webRoot, "src/module-registry.generated.ts");
|
||||||
|
const featuresPath = path.join(webRoot, "teaching/data/features.json");
|
||||||
|
const casesPath = path.join(webRoot, "teaching/data/cases.json");
|
||||||
|
const ledgerPath = path.join(webRoot, "docs/current/freecad-official-case-ledger.json");
|
||||||
|
|
||||||
|
const matrix = readJson(matrixPath);
|
||||||
|
const routes = readJson(routesPath);
|
||||||
|
const features = readJson(featuresPath);
|
||||||
|
const cases = readJson(casesPath);
|
||||||
|
const ledger = readJson(ledgerPath);
|
||||||
|
|
||||||
|
const chapters = [
|
||||||
|
{ id: "ch00", order: 0, level: "core", title: "导读、启动与 OPFS", moduleIds: ["Start", "Web", "Help"] },
|
||||||
|
{ id: "ch01", order: 1, level: "core", title: "界面、文档与视图", moduleIds: [] },
|
||||||
|
{ id: "ch02", order: 2, level: "core", title: "Part 图元与布尔", moduleIds: ["Part"] },
|
||||||
|
{ id: "ch03", order: 3, level: "core", title: "Sketcher 草图", moduleIds: ["Sketcher"] },
|
||||||
|
{ id: "ch04", order: 4, level: "core", title: "PartDesign 实体建模", moduleIds: ["PartDesign"] },
|
||||||
|
{ id: "ch05", order: 5, level: "core", title: "Assembly 装配", moduleIds: ["Assembly"] },
|
||||||
|
{ id: "ch06", order: 6, level: "core", title: "测量、检查、材质与表格", moduleIds: ["Measure", "Inspection", "Material", "Spreadsheet"] },
|
||||||
|
{ id: "ch07", order: 7, level: "core", title: "导入导出与 OPFS", moduleIds: ["Import"] },
|
||||||
|
{ id: "ch08", order: 8, level: "specialist", title: "网格、点、逆向与曲面", moduleIds: ["Mesh", "MeshPart", "Points", "ReverseEngineering", "Surface"] },
|
||||||
|
{ id: "ch09", order: 9, level: "specialist", title: "BIM 建筑信息模型", moduleIds: ["BIM"] },
|
||||||
|
{ id: "ch10", order: 10, level: "specialist", title: "CAM 加工", moduleIds: ["CAM"] },
|
||||||
|
{ id: "ch11", order: 11, level: "specialist", title: "TechDraw 工程图", moduleIds: ["TechDraw"] },
|
||||||
|
{ id: "ch12", order: 12, level: "specialist", title: "FEM 有限元", moduleIds: ["Fem"] },
|
||||||
|
{ id: "ch13", order: 13, level: "specialist", title: "Draft、Plot、OpenSCAD 等", moduleIds: ["Draft", "Plot", "OpenSCAD", "Robot", "Cloud", "JtReader", "Sandbox", "Test", "Tux", "TemplatePyMod", "Show"] },
|
||||||
|
{ id: "ch14", order: 14, level: "case", title: "综合案例:27 件 GLB 产线", moduleIds: [] },
|
||||||
|
{ id: "ch15", order: 15, level: "appendix", title: "附录:命令索引与缺口", moduleIds: [] },
|
||||||
|
];
|
||||||
|
|
||||||
|
const moduleChapter = new Map();
|
||||||
|
for (const chapter of chapters) for (const moduleId of chapter.moduleIds) moduleChapter.set(moduleId, chapter.id);
|
||||||
|
const moduleOfChapter = id => chapters.find(chapter => chapter.id === id);
|
||||||
|
|
||||||
|
const boundaries = [
|
||||||
|
{ id: "b-techdraw-worker", module: "TechDraw", match: ["TechDraw_PageDefault"],
|
||||||
|
title: "TechDraw 跨 Worker 文档桥", detail: "页面 Worker 未持有目标文档,TechDraw_PageDefault 报 Document does not exist;SVG 回退不是 TechDraw 输出。",
|
||||||
|
desktopRefs: ["freecad-source/src/Mod/TechDraw/App/DrawPage.cpp", "freecad-source/src/Mod/TechDraw/App/DrawViewPart.cpp"] },
|
||||||
|
{ id: "b-fem-native", module: "Fem", match: ["FEM_ResultShow", "PostPipelineFromResult"],
|
||||||
|
title: "FEM 原生结果对象", detail: "FemMeshObject/FemResultObject 未随包发布,结果停留在 Worker;VTK 显示为 three.js 近似。",
|
||||||
|
desktopRefs: ["freecad-source/src/Mod/Fem/App/FemMeshObject.cpp", "web/docs/current/web-freecad-gaps-fem.md"] },
|
||||||
|
{ id: "b-cam-opencamlib", module: "CAM", match: ["CAM_Adaptive", "CAM_Surface", "CAM_Waterline"],
|
||||||
|
title: "CAM OpenCAMLib 路径", detail: "Adaptive/Surface/Waterline 依赖 OpenCAMLib 与完整 ToolBit/G-code 栈,WASM 包未提供。",
|
||||||
|
desktopRefs: ["freecad-source/src/Mod/CAM/App/AppPath.cpp", "web/docs/current/cam-teaching-gap.md"] },
|
||||||
|
{ id: "b-gltf-native", module: "Import", match: ["Import_Gltf"],
|
||||||
|
title: "glTF 原生导入/导出", detail: "OCCT WASM 构建 USE_RAPIDJSON=OFF,RWGltf 无法读写;当前仅 three.js 查看。",
|
||||||
|
desktopRefs: ["freecad-source/src/Mod/Import/App/ReaderGltf.cpp", "freecad-source/src/Mod/Import/App/WriterGltf.cpp"] },
|
||||||
|
{ id: "b-cloud-remote", module: "Cloud", match: [],
|
||||||
|
title: "Cloud 远程存储", detail: "Save/Restore 需要远程 S3 凭据与服务;本地 OPFS 不受影响。",
|
||||||
|
desktopRefs: ["web/src/cloud.worker.ts"] },
|
||||||
|
];
|
||||||
|
const boundaryByKey = new Map();
|
||||||
|
for (const boundary of boundaries) for (const command of boundary.match) boundaryByKey.set(`${boundary.module}:${command}`, boundary);
|
||||||
|
|
||||||
|
// User-facing command catalogs (regex extraction is deliberate: these files are
|
||||||
|
// the UI source of truth and are validated by capture later).
|
||||||
|
const uiCommands = new Set();
|
||||||
|
for (const relative of ["src/part-workbench-ui.tsx", "src/partdesign-desktop-adapter.ts", "src/sketcher-desktop-adapter.ts"]) {
|
||||||
|
const text = fs.readFileSync(path.join(webRoot, relative), "utf8");
|
||||||
|
for (const match of text.matchAll(/\b(?:Part|PartDesign|Sketcher)_[A-Za-z0-9_]+/g)) uiCommands.add(match[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Passed cases keyed by desktop command for status hints (capture still decides verified).
|
||||||
|
const caseByCommand = new Map();
|
||||||
|
for (const item of cases.cases ?? []) {
|
||||||
|
if (!item.command) continue;
|
||||||
|
if (!(item.checks ?? []).find(check => check.flag === "acceptancePassed")?.passed) continue;
|
||||||
|
caseByCommand.set(item.command, item.caseId);
|
||||||
|
}
|
||||||
|
|
||||||
|
const commands = [];
|
||||||
|
const moduleSeen = new Set();
|
||||||
|
for (const record of matrix.records ?? []) {
|
||||||
|
const chapterId = moduleChapter.get(record.module) ?? null;
|
||||||
|
moduleSeen.add(record.module);
|
||||||
|
const boundary = boundaryByKey.get(`${record.module}:${record.command}`) ?? null;
|
||||||
|
const ui = uiCommands.has(record.command);
|
||||||
|
const native = record.disposition === "native_handler";
|
||||||
|
const level = chapterId ? moduleOfChapter(chapterId)?.level : null;
|
||||||
|
let status = "overview";
|
||||||
|
if (boundary) status = "boundary";
|
||||||
|
else if (level === "core" && (native || ui)) status = "detailed";
|
||||||
|
else if (level === "specialist" && (native || ui)) status = "overview";
|
||||||
|
commands.push({
|
||||||
|
key: record.id ?? `${record.module}:desktop:${record.command}`,
|
||||||
|
module: record.module,
|
||||||
|
command: record.command,
|
||||||
|
kind: record.kind ?? "desktop",
|
||||||
|
disposition: record.disposition ?? "unknown",
|
||||||
|
route: record.route ?? null,
|
||||||
|
chapterId,
|
||||||
|
workflowId: null,
|
||||||
|
status,
|
||||||
|
uiSurface: ui,
|
||||||
|
ledgerCaseId: caseByCommand.get(record.command) ?? null,
|
||||||
|
boundaryId: boundary?.id ?? null,
|
||||||
|
screenshotId: null,
|
||||||
|
sourcePath: record.sourcePath ?? null,
|
||||||
|
sourceLine: record.sourceLine ?? null,
|
||||||
|
desktopRef: record.sourcePath ? `${record.sourcePath}:${record.sourceLine ?? ""}` : null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Registry-only routes that do not appear in the desktop matrix still belong in
|
||||||
|
// the appendix (e.g. assembly.createRecompute).
|
||||||
|
const matrixKeys = new Set(commands.map(item => `${item.module}:${item.command}`));
|
||||||
|
for (const module of features.modules ?? []) {
|
||||||
|
const chapterId = moduleChapter.get(module.module) ?? null;
|
||||||
|
if (!chapterId) throw new Error(`registry module has no chapter: ${module.module}`);
|
||||||
|
for (const command of module.commands ?? []) {
|
||||||
|
if (matrixKeys.has(`${module.module}:${command}`)) continue;
|
||||||
|
matrixKeys.add(`${module.module}:${command}`);
|
||||||
|
commands.push({
|
||||||
|
key: `${module.module}:web:${command}`, module: module.module, command,
|
||||||
|
kind: "web-route", disposition: "registered", route: null,
|
||||||
|
chapterId, workflowId: null, status: "overview", uiSurface: false,
|
||||||
|
ledgerCaseId: null, boundaryId: null, screenshotId: null,
|
||||||
|
sourcePath: null, sourceLine: null, desktopRef: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const unknownModules = [...moduleSeen].filter(module => !moduleChapter.has(module));
|
||||||
|
if (unknownModules.length) throw new Error(`modules without chapter: ${unknownModules.join(", ")}`);
|
||||||
|
const nativeUnmapped = commands.filter(item => item.disposition === "native_handler" && !item.chapterId);
|
||||||
|
if (nativeUnmapped.length) throw new Error(`native handlers without chapter: ${nativeUnmapped.length}`);
|
||||||
|
|
||||||
|
const stats = {
|
||||||
|
modules: moduleSeen.size,
|
||||||
|
commands: commands.length,
|
||||||
|
desktopRecords: matrix.records?.length ?? 0,
|
||||||
|
routes: routes.records?.length ?? 0,
|
||||||
|
registryCommands: (features.modules ?? []).reduce((sum, module) => sum + (module.commands?.length ?? 0), 0),
|
||||||
|
nativeHandlers: commands.filter(item => item.disposition === "native_handler").length,
|
||||||
|
detailed: commands.filter(item => item.status === "detailed").length,
|
||||||
|
overview: commands.filter(item => item.status === "overview").length,
|
||||||
|
boundary: commands.filter(item => item.status === "boundary").length,
|
||||||
|
verifiedCandidates: commands.filter(item => item.ledgerCaseId).length,
|
||||||
|
screenshots: 0,
|
||||||
|
workflows: 0,
|
||||||
|
};
|
||||||
|
const coverage = {
|
||||||
|
schema: "freecad-web-manual/coverage/v1",
|
||||||
|
generatedAt: new Date().toISOString(),
|
||||||
|
modules: moduleSeen.size,
|
||||||
|
unknownModules,
|
||||||
|
nativeHandlers: stats.nativeHandlers,
|
||||||
|
nativeMapped: stats.nativeHandlers,
|
||||||
|
desktopRecords: stats.desktopRecords,
|
||||||
|
registryCommands: stats.registryCommands,
|
||||||
|
routes: stats.routes,
|
||||||
|
byChapter: Object.fromEntries(chapters.map(chapter => [chapter.id,
|
||||||
|
commands.filter(item => item.chapterId === chapter.id).length])),
|
||||||
|
byStatus: Object.fromEntries(["detailed", "overview", "boundary"].map(status =>
|
||||||
|
[status, commands.filter(item => item.status === status).length])),
|
||||||
|
ok: unknownModules.length === 0 && stats.nativeHandlers === stats.nativeHandlers,
|
||||||
|
};
|
||||||
|
const sources = [matrixPath, routesPath, registryPath, featuresPath, casesPath, ledgerPath]
|
||||||
|
.map(file => ({ path: path.relative(webRoot, file), sha256: sha256(file) }));
|
||||||
|
const output = {
|
||||||
|
schema: "freecad-web-manual/features/v1",
|
||||||
|
generatedAt: new Date().toISOString(),
|
||||||
|
sources,
|
||||||
|
stats,
|
||||||
|
chapters,
|
||||||
|
workflows: [],
|
||||||
|
commands,
|
||||||
|
screenshots: [],
|
||||||
|
boundaries,
|
||||||
|
};
|
||||||
|
fs.writeFileSync(path.join(outDir, "manual-features.json"), `${JSON.stringify(output, null, 2)}\n`);
|
||||||
|
fs.writeFileSync(path.join(outDir, "inventory-snapshot.json"), `${JSON.stringify({
|
||||||
|
schema: "freecad-web-manual/inventory/v1", generatedAt: output.generatedAt, sources,
|
||||||
|
}, null, 2)}\n`);
|
||||||
|
fs.writeFileSync(path.join(outDir, "coverage-audit.json"), `${JSON.stringify(coverage, null, 2)}\n`);
|
||||||
|
console.log(JSON.stringify({ ok: true, stats, coverage: coverage.byChapter }));
|
||||||
177
web/tools/manual/template.html
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<link rel="icon" href="data:," />
|
||||||
|
<title>{{TITLE}}</title>
|
||||||
|
<style>
|
||||||
|
:root { color-scheme: dark; --bg:#0f1419; --panel:#17212b; --line:#2a3a45; --text:#dbe6ee; --muted:#93a6b3; --accent:#73c6d4; --warn:#e0b15c; --ok:#7fc98b; }
|
||||||
|
* { box-sizing: border-box; }
|
||||||
|
html { scroll-behavior: smooth; }
|
||||||
|
body { margin:0; background:var(--bg); color:var(--text); font:15px/1.7 system-ui,"Noto Sans SC",sans-serif; }
|
||||||
|
a { color:var(--accent); text-decoration:none; }
|
||||||
|
header.top { position:sticky; top:0; z-index:30; display:flex; align-items:center; gap:12px; padding:10px 18px; background:#0b1116f2; border-bottom:1px solid var(--line); backdrop-filter:blur(6px); }
|
||||||
|
header.top h1 { margin:0; font-size:17px; flex:0 0 auto; }
|
||||||
|
#search { margin-left:auto; width:min(420px,42vw); background:#0b1014; color:var(--text); border:1px solid #3f3f3f; border-radius:6px; padding:6px 10px; }
|
||||||
|
#search-results { position:fixed; top:52px; right:18px; width:min(520px,90vw); max-height:60vh; overflow:auto; background:#0d1318; border:1px solid var(--line); border-radius:8px; box-shadow:0 12px 32px #0008; z-index:40; display:none; }
|
||||||
|
#search-results a { display:block; padding:8px 12px; border-bottom:1px solid #1d2a33; color:var(--text); }
|
||||||
|
#search-results a small { display:block; color:var(--muted); }
|
||||||
|
#menu-toggle { display:none; background:transparent; color:var(--text); border:1px solid #3f3f3f; border-radius:4px; padding:4px 8px; }
|
||||||
|
.layout { display:grid; grid-template-columns:290px minmax(0,1fr); gap:0; max-width:1500px; margin:0 auto; }
|
||||||
|
nav.sidebar { position:sticky; top:53px; height:calc(100vh - 53px); overflow:auto; border-right:1px solid var(--line); padding:14px 12px 40px; }
|
||||||
|
nav.sidebar .progress { height:8px; background:var(--panel); border-radius:4px; overflow:hidden; margin:6px 0 12px; }
|
||||||
|
nav.sidebar .progress span { display:block; height:100%; width:0; background:var(--accent); }
|
||||||
|
nav.sidebar ol { list-style:none; margin:0; padding:0; }
|
||||||
|
nav.sidebar li { margin:2px 0; }
|
||||||
|
nav.sidebar a { display:block; padding:4px 6px; border-radius:4px; color:var(--text); font-size:13.5px; }
|
||||||
|
nav.sidebar a:hover, nav.sidebar a.active { background:#22313b; color:var(--accent); }
|
||||||
|
nav.sidebar .chapter { display:flex; align-items:center; gap:6px; margin-top:8px; }
|
||||||
|
nav.sidebar .chapter input { accent-color:var(--accent); }
|
||||||
|
nav.sidebar .sec { padding-left:16px; color:var(--muted); font-size:12.5px; }
|
||||||
|
main { padding:24px 30px 80px; min-width:0; }
|
||||||
|
main h1 { font-size:26px; margin:0 0 14px; }
|
||||||
|
main h2 { font-size:20px; margin:36px 0 12px; padding-top:8px; border-top:1px solid var(--line); color:var(--accent); }
|
||||||
|
main h3 { font-size:16px; margin:24px 0 8px; }
|
||||||
|
main p, main li { max-width:900px; }
|
||||||
|
main img { display:block; max-width:100%; height:auto; border:1px solid var(--line); border-radius:8px; background:#0d1318; margin:12px 0; cursor:zoom-in; }
|
||||||
|
main figure { margin:16px 0; }
|
||||||
|
main figcaption { color:var(--muted); font-size:12.5px; }
|
||||||
|
.table-scroll { max-width:100%; overflow-x:auto; }
|
||||||
|
table { width:100%; border-collapse:collapse; font-size:13px; margin:12px 0; }
|
||||||
|
th, td { border-bottom:1px solid var(--line); padding:5px 7px; text-align:left; vertical-align:top; }
|
||||||
|
th { color:var(--accent); }
|
||||||
|
code, pre { background:#0b1014; border:1px solid #22303a; border-radius:5px; }
|
||||||
|
code { padding:1px 4px; font-size:12.5px; }
|
||||||
|
pre { padding:10px; overflow:auto; }
|
||||||
|
blockquote { border-left:3px solid var(--warn); margin:12px 0; padding:4px 12px; color:var(--warn); background:#1d1a1210; }
|
||||||
|
.cmd { font-family:ui-monospace,monospace; font-size:12px; color:#9fd6de; }
|
||||||
|
.badge { display:inline-block; border-radius:4px; padding:0 6px; font-size:11px; border:1px solid var(--line); }
|
||||||
|
.badge.detailed { color:var(--ok); } .badge.overview { color:var(--accent); } .badge.boundary { color:var(--warn); }
|
||||||
|
.index-controls { display:flex; gap:8px; flex-wrap:wrap; margin:12px 0; }
|
||||||
|
.index-controls select, .index-controls input { background:#0b1014; color:var(--text); border:1px solid #3f3f3f; border-radius:4px; padding:5px 8px; }
|
||||||
|
#command-index td { font-size:12px; } #command-index tr.hidden { display:none; }
|
||||||
|
.pager { display:flex; justify-content:space-between; gap:12px; margin-top:40px; padding-top:14px; border-top:1px solid var(--line); }
|
||||||
|
#lightbox { position:fixed; inset:0; background:#000d; z-index:60; display:none; align-items:center; justify-content:center; padding:24px; }
|
||||||
|
#lightbox img { max-width:96vw; max-height:92vh; border-radius:6px; }
|
||||||
|
#lightbox.open { display:flex; }
|
||||||
|
@media (max-width:900px) {
|
||||||
|
.layout { grid-template-columns:1fr; }
|
||||||
|
nav.sidebar { position:fixed; z-index:35; top:53px; left:0; width:280px; background:#0d1318; transform:translateX(-100%); transition:transform .2s; }
|
||||||
|
nav.sidebar.open { transform:translateX(0); }
|
||||||
|
#menu-toggle { display:inline-block; }
|
||||||
|
main { padding:18px 14px 60px; }
|
||||||
|
header.top { gap:8px; padding:8px 10px; }
|
||||||
|
header.top h1 { font-size:14px; max-width:34vw; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
||||||
|
#search { width:auto; flex:1; min-width:0; margin-left:6px; }
|
||||||
|
}
|
||||||
|
@media print { header.top, nav.sidebar, #lightbox, .pager { display:none; } .layout { display:block; } main { padding:0; } main img { break-inside:avoid; } }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="top">
|
||||||
|
<button id="menu-toggle" aria-label="Toggle navigation">☰</button>
|
||||||
|
<h1>{{TITLE}}</h1>
|
||||||
|
<input id="search" type="search" placeholder="搜索章节、命令、参数…(/ 聚焦)" aria-label="搜索教案" />
|
||||||
|
</header>
|
||||||
|
<div id="search-results" role="listbox" aria-label="搜索结果"></div>
|
||||||
|
<div class="layout">
|
||||||
|
<nav class="sidebar" id="sidebar" aria-label="章节目录">
|
||||||
|
<strong>课程进度</strong>
|
||||||
|
<div class="progress"><span id="progress-bar"></span></div>
|
||||||
|
<p id="progress-text" style="color:var(--muted);font-size:12px;margin:0 0 8px"></p>
|
||||||
|
{{SIDEBAR}}
|
||||||
|
</nav>
|
||||||
|
<main id="content">
|
||||||
|
{{CONTENT}}
|
||||||
|
{{COMMAND_INDEX}}
|
||||||
|
<div class="pager" id="pager"></div>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
<div id="lightbox" role="dialog" aria-label="图片预览"><img alt="" /></div>
|
||||||
|
<script>
|
||||||
|
const SEARCH_INDEX = {{SEARCH_INDEX}};
|
||||||
|
const COMMAND_COUNT = {{COMMAND_COUNT}};
|
||||||
|
const boxes = [...document.querySelectorAll('input[data-progress]')];
|
||||||
|
const key = 'web-freecad-manual-progress-v1';
|
||||||
|
const loadProgress = () => { try { return JSON.parse(localStorage.getItem(key) || '{}'); } catch { return {}; } };
|
||||||
|
const saveProgress = value => localStorage.setItem(key, JSON.stringify(value));
|
||||||
|
const renderProgress = () => {
|
||||||
|
const done = boxes.filter(box => box.checked).length;
|
||||||
|
document.getElementById('progress-bar').style.width = boxes.length ? (100 * done / boxes.length) + '%' : '0';
|
||||||
|
document.getElementById('progress-text').textContent = done + ' / ' + boxes.length + ' 章已完成';
|
||||||
|
};
|
||||||
|
const state = loadProgress();
|
||||||
|
for (const box of boxes) {
|
||||||
|
box.checked = Boolean(state[box.dataset.progress]);
|
||||||
|
box.addEventListener('change', () => { const value = loadProgress(); value[box.dataset.progress] = box.checked; saveProgress(value); renderProgress(); });
|
||||||
|
}
|
||||||
|
renderProgress();
|
||||||
|
const sidebar = document.getElementById('sidebar');
|
||||||
|
document.getElementById('menu-toggle').addEventListener('click', () => sidebar.classList.toggle('open'));
|
||||||
|
for (const link of sidebar.querySelectorAll('a[href^="#"]')) link.addEventListener('click', () => sidebar.classList.remove('open'));
|
||||||
|
|
||||||
|
const search = document.getElementById('search');
|
||||||
|
const results = document.getElementById('search-results');
|
||||||
|
const normalize = text => String(text || '').toLowerCase().replace(/\s+/g, ' ').trim();
|
||||||
|
const renderResults = query => {
|
||||||
|
const q = normalize(query);
|
||||||
|
results.innerHTML = '';
|
||||||
|
if (q.length < 1) { results.style.display = 'none'; return; }
|
||||||
|
const hits = SEARCH_INDEX.filter(item => normalize(item.title + ' ' + item.text + ' ' + (item.commands || []).join(' ')).includes(q)).slice(0, 30);
|
||||||
|
for (const hit of hits) {
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = '#' + hit.id;
|
||||||
|
link.innerHTML = '<strong>' + hit.title + '</strong><small>' + hit.chapter + ' · ' + hit.text.slice(0, 90).replace(/</g, '<') + '</small>';
|
||||||
|
results.appendChild(link);
|
||||||
|
}
|
||||||
|
if (!hits.length) results.innerHTML = '<p style="padding:10px;color:#93a6b3">没有匹配结果</p>';
|
||||||
|
results.style.display = 'block';
|
||||||
|
};
|
||||||
|
search.addEventListener('input', () => renderResults(search.value));
|
||||||
|
search.addEventListener('keydown', event => { if (event.key === 'Escape') { results.style.display = 'none'; search.blur(); } });
|
||||||
|
document.addEventListener('keydown', event => {
|
||||||
|
if (event.key === '/' && document.activeElement !== search) { event.preventDefault(); search.focus(); }
|
||||||
|
if (event.key === 'Escape') document.getElementById('lightbox').classList.remove('open');
|
||||||
|
});
|
||||||
|
results.addEventListener('click', event => { if (event.target.closest('a')) results.style.display = 'none'; });
|
||||||
|
|
||||||
|
const lightbox = document.getElementById('lightbox');
|
||||||
|
for (const image of document.querySelectorAll('main img')) {
|
||||||
|
image.addEventListener('click', () => { lightbox.querySelector('img').src = image.src; lightbox.classList.add('open'); });
|
||||||
|
}
|
||||||
|
lightbox.addEventListener('click', () => lightbox.classList.remove('open'));
|
||||||
|
|
||||||
|
const moduleFilter = document.getElementById('filter-module');
|
||||||
|
const statusFilter = document.getElementById('filter-status');
|
||||||
|
const indexSearch = document.getElementById('filter-command');
|
||||||
|
const rows = [...document.querySelectorAll('#command-index tbody tr')];
|
||||||
|
const applyFilter = () => {
|
||||||
|
const module = moduleFilter?.value || '';
|
||||||
|
const status = statusFilter?.value || '';
|
||||||
|
const text = normalize(indexSearch?.value || '');
|
||||||
|
for (const row of rows) {
|
||||||
|
const ok = (!module || row.dataset.module === module) && (!status || row.dataset.status === status)
|
||||||
|
&& (!text || normalize(row.textContent).includes(text));
|
||||||
|
row.classList.toggle('hidden', !ok);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
for (const control of [moduleFilter, statusFilter, indexSearch]) control?.addEventListener('input', applyFilter);
|
||||||
|
|
||||||
|
const heads = [...document.querySelectorAll('main h2[id]')];
|
||||||
|
const links = new Map([...sidebar.querySelectorAll('a[href^="#"]')].map(link => [link.getAttribute('href').slice(1), link]));
|
||||||
|
const spy = () => {
|
||||||
|
let current = null;
|
||||||
|
for (const head of heads) if (head.getBoundingClientRect().top < 120) current = head.id;
|
||||||
|
for (const [id, link] of links) link.classList.toggle('active', id === current);
|
||||||
|
};
|
||||||
|
document.addEventListener('scroll', spy, { passive: true }); spy();
|
||||||
|
|
||||||
|
const chapters = [...document.querySelectorAll('main h1[id]')];
|
||||||
|
const pager = document.getElementById('pager');
|
||||||
|
if (chapters.length > 1) {
|
||||||
|
// Multi-chapter pages are not used; the pager stays empty for now.
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||