fix: restore the page content call and stop writing the registry

- render_active_document passed the tab id as the first __setContent argument,
  but the page signature starts with previewHtml, so #preview rendered the tab
  id ("1", "2", "3" as tabs were opened) and the window looked blank. The call
  now goes through set_content_script(), and a test pins the exact script plus
  the page signature so the two cannot drift silently.
- remove register_as_default() and the winreg dependency: the app no longer
  writes HKCU on launch. publish.ps1 still refreshes the .md association.
This commit is contained in:
2026-11-04 15:25:13 +08:00
parent 0b97bcb6dc
commit 590a9a016c
6 changed files with 74 additions and 161 deletions

View File

@@ -28,12 +28,12 @@
## 4. 待做功能(都需要先讨论/确认)
### 4.1 移除应用自身的 HKCU 写入(已定方向,未实施)
### 4.1 移除应用自身的 HKCU 写入(2026-11-04 已完成)
- 删除 `main()` 里的 `register_as_default()` 调用和该函数(`src/main.rs`);应用不再写注册表。
- 已删除 `main()` 里的 `register_as_default()` 调用、该函数以及 `winreg` 依赖;应用不再写注册表。
- **`publish.ps1` 维持现状**(继续写 ProgID/关联),这是用户明确决定。
- 影响:新机器上应用不再自动出现在“打开方式”;用户通过 Windows 设置选择一次默认应用;exe 移动后由发布脚本刷新关联。
- 需要同步:README“下载与运行”里的关联说明、STATUS 的注册表相关条目。
- 影响:新机器上应用不再自动出现在“打开方式”;首次在 Windows“打开方式 → 选择其他应用”里选一次;exe 移动后由发布脚本刷新关联。
- README 第 3 步、STATUS §11 已同步。
### 4.2 编辑区样式化(需求已明确,实现未选型)
@@ -85,11 +85,12 @@ cd D:\Scripts\md-preview\AgentLowWorking
- mjs 通过 CDP 读取页面快照、断言(页面加载、`#preview` 有内容、`window.ipc` 桥、页面 API、标题/折叠按钮/代码高亮),再截图,写 `target/ui-test/ui-smoke.json` 与 `ui-smoke.png`。
- Agent 可以直接读这两个文件定位问题;失败时把 report 里的 checks 贴出来即可。
- 已知边界:只验证“页面真的渲染了 + 基础 API 在”,不覆盖标签切换、保存、外部修改等 Rust 侧流程(那些靠单元测试和人工点)。
- 注意:如果用 `-Exe` 指向 Nutstore 的发布版(Medium),启动会写 HKCU 关联(应用原有行为,指向它自己);默认的开发构建是 Low,写不了注册表。
- 2026-11-04 起应用启动不再写注册表,所以用发布版做冒烟也不会改 .md 关联;默认的开发构建仍是 Low,配置目录隔离在 `target/ui-test`。
## 6. 注意
- 本仓库现在**只能在 Windows 上编译**;`cargo test` 里仍有 `cfg(target_os = "windows")` 的 Windows 专用测试。
- `main.rs` 顶部的 `windows_subsystem` 只对 release 生效;debug 构建带控制台,属正常。
- 页面 JS 改动后建议做一次语法检查(临时测试把页面写到文件,再 `node --check`)。
- **Rust → JS 调用没有编译器检查**:改 `__setContent` / `__setPreview` 等参数列表时,必须同步改页面的函数签名,并用 `set_content_script_matches_the_page_signature` 这类“精确输出 + 页面签名”测试锁住。2026-11-04 的白屏就是这么来的(多传了一个 `active.id`,标签 id 被当 HTML 渲染)。
- 构建/测试临时文件放 `target\tmp`;不要写 `%TEMP%`。