Files
FreeCADWasmDev/web/docs/current/desktop-parity-continuation.md
2026-11-13 22:57:13 +08:00

108 lines
6.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Web FreeCAD 桌面功能与 GUI 对标 · 接续点
更新:2026-11-13
计划:`/home/mes123456/.claude/plans/partitioned-puzzling-haven.md`
## 目标
统一 React 桌面式单壳;32 模块功能/GUI 对标;OPFS 文件;three.js 图形;
逐 workbench 截图 + 1492 命令矩阵 + 324 官方案例验收。
## 已完成(P0)
- **桌面参照可运行**:找到 `freecad-source/build/native-release/bin/FreeCAD`(GUI)
与 `FreeCADCmd`(控制台)。补齐缺失 GUI 模块(PartGui/SketcherGui/PartDesignGui/
TechDrawGui/FemGui/MeshGui/StartGui 等 18 个 `.so`)。
- 修复桌面源码编译缺口:
- `src/Gui/CommandStd.cpp` 增加 `NetworkRetriever.h` 引用;
- `src/Gui/NetworkRetriever.h/.cpp` 补 `StdCmdDownloadOnlineHelp::updateAction/className`;
- `src/Mod/Mesh/Gui/RemeshGmsh.cpp` `countFacets()` → `CountFacets()`。
- Xvfb `:2` 截图:`web/docs/current/desktop-parity-evidence/Part-desktop.png`。
- **桌面 GUI 清单**:`tools/parity/extract-desktop-gui.mjs`
- 输出 `web/public/api/desktop-gui-manifest.json`:29 个 GUI workbench(Plot/Show/Web
无桌面 workbench)、1492 命令记录、309 菜单命令、237 工具栏命令、746 条命令元数据。
- 输出 `web/docs/current/desktop-parity-matrix.json` 与
`web/public/api/gui-command-gap-report.json`:
implemented 3 / native-ui-check 196 / gui-route-missing 425 / gui-missing 865 / boundary 3。
- **Web 基线审计**:`tools/parity/audit-web-gui.mjs --workbench Part`
- 输出 `Part-web.png` 与 `Part-web-audit.json`;0 错误/0 溢出;
缺失菜单仅 `Part_ColorPerFace`(解析器伪菜单,后续修正)。
## 已完成(P1 骨架)
- `web/src/shell/`:
- `command-registry.ts`:加载 `desktop-gui-manifest.json`,提供 workbench/命令元数据;
- `menu-bar.tsx`:File/Edit/View/Tools/Macro/Windows/Help + 工作台菜单,支持子菜单与命令;
- `toolbar.tsx`:按 manifest 渲染工作台工具栏;
- `shell-preview.tsx` + `shell-preview.html`:29 个 workbench 选择器、菜单/工具栏、
three.js 预览视口(网格/坐标轴/Box)、属性/树/状态栏。
- 页面检查:`http://127.0.0.1:5181/shell-preview.html` 29 个 workbench、3 个工具栏、
0 pageError、0 横向溢出;截图
`web/docs/current/desktop-parity-evidence/shell-preview.png`。
- **project-shell 已接入 manifest 工作台菜单**:
- `web/src/shell/workbench-menu.tsx`:非 Part 工作台显示 manifest 菜单/子菜单;
- Workbench 选择器扩展到 29 个模块(Part 保持原有 `PartWorkbenchMenu`);
- 选中 BIM 后菜单显示 2D Drafting / 3D/BIM / Annotation / Manage / Flamingo /
Fasteners / Utils;截图 `BIM-web-menu.png`;
- Part 回归审计仍 0 错误/0 溢出。
- **非 Part 工具栏已接入**:`web/src/shell/workbench-toolbars.tsx` +
`toolbar.tsx` 渲染 manifest 工具栏并复用 TaskFrame 回调。
BIM 实测 8 组工具栏 / 73 个按钮,0 pageError、0 溢出;
截图 `BIM-toolbars.png`。命令标签已做人类化回退(`BIM_TogglePanels` → Toggle Panels)。
- **Tools/Help 菜单与偏好对话框**:`shell/utility-menus.tsx` +
`shell/preferences-dialog.tsx`。Preferences 支持单位制、导航风格、主题、网格,
写入 `localStorage`;截图 `preferences-dialog.png`;0 pageError。
- **快捷键**:`shell/shortcut-manager.tsx`
- 全局快捷键监听(忽略输入框),按 manifest accel + localStorage 覆盖执行命令;
- Tools → Customize shortcuts 打开编辑器,746 条命令可搜索/录入/清除;
- 截图 `shortcut-editor.png`,0 pageError。
- **偏好已写入 OPFS**:`shell/settings-store.ts` 基于 `parameter-storage.ts` 的
`persist/saved`,保存到 `freecad-parameters/web-preferences.json`。
实测切换单位制后文件为 98 字节、内容含 `MKS (m, kg, s, °)`;localStorage 仍作缓存。
- **底部停靠面板**:`shell/bottom-dock.tsx` + Windows 菜单入口。
- Selection view 显示当前选择对象;Report view 保留最近 50 条状态;
- 实测打开/切换正常,0 pageError;截图 `bottom-dock.png`。
- **单位制已驱动属性显示**:`shell/units.ts`;Preferences 修改后广播
`freecad-preferences-changed`,属性面板 Bounds 标签与数值、Volume 按 mm/m/in/cm
换算显示。实测 mm → m 切换生效,0 pageError。
- 输入框仍以 mm 写入内核,显示层换算;原生 `BaseApp/Preferences` 同步待 P3。
- **快捷键已写入 OPFS**:`freecad-parameters/web-shortcuts.json`;
实测录制 `Ctrl+Shift+K` 后文件内容 `{"Std_About":"Ctrl+Shift+K"}`,0 pageError。
运行时仍优先 localStorage 缓存,OPFS 作为持久层。
- 说明:Python 控制台尚未接入;原生 Shortcut 参数同步待 P3。
- 非 Part 菜单命令改为打开 **React TaskFrame 模态**(`web/src/shell/task-frame.tsx`),
iframe 复用 `/workbench.html?module=<id>&command=<id>` 的现有任务面板;
BIM_TogglePanels 实测弹出 "Bottom panels" 任务并可点按钮,0 pageError;
截图 `BIM-task-frame.png`。统一执行/文档共享仍待 P2 的原生任务桥。
- Python InitGui 解析改为位置感知变量解析(`self.*`、重赋值、`+` 拼接),
菜单命令 513、工具栏命令 362,gui-missing 降至 623。
- 说明:preview 页仅渲染清单与命令回调;统一执行路由尚待 P2/P3。
## 真实残余
- 统一桌面壳尚未实现:project-shell 仍只支持 9 个 workbench、菜单仅 Start/File/Edit/View/Part;
`workbench.html`/`partdesign.html` 仍是独立壳。
- `gui-route-missing` 425、`gui-missing` 865 尚未逐条分配 React owner。
- 桌面清单解析仍有伪菜单(Part_ColorPerFace、空 submenu),需过滤与层次修正。
- 桌面 GUI 启动有 `--no-sandbox` 警告横幅(来自环境变量),截图时需裁掉或清理环境。
- 桌面源码改动(3 文件)与 Web 工具/清单尚未提交。
## 下一步精确入口
1. 清理并提交:`tools/parity/extract-desktop-gui.mjs`、`audit-web-gui.mjs`、
`web/public/api/{desktop-gui-manifest,gui-command-gap-report}.json`、
`web/docs/current/desktop-parity-*`;桌面 3 个源码修复单独提交。
2. 把 `shell-preview` 的菜单/工具栏挂入 `project-shell.tsx`,用 command registry
替换静态菜单;Part 先接通 `activatePartAction`,其余 workbench 接 `desktopCommands`/
`workbench-registry`;旧页面重定向。
3. 修正解析器:去掉空/伪菜单,保留菜单层级;补 Python InitGui 的菜单/工具栏。
4. 每完成一个 workbench:`audit-web-gui.mjs --workbench <id>` 截图 + 差异 JSON。
## 关键路径
- 桌面 GUI:`freecad-source/build/native-release/bin/FreeCAD`
- 桌面源码:`freecad-source/src/Gui`、`freecad-source/src/Mod/*/Gui`
- Web 壳:`web/src/project-shell.tsx`、`web/src/workbench-shell.tsx`
- 清单/审计:`tools/parity/`、`web/public/api/desktop-gui-manifest.json`
- 证据:`web/docs/current/desktop-parity-evidence/`