chore(dev): 新增 Windows 本地实时预览脚本 win:dev (不打包)
Docker Build and Push / build-image (push) Successful in 2m31s

改完前端 UI 想立刻在 Windows 外壳里看效果, 原本要 tauri build 打包。实际外壳
用 tauri-plugin-hotswap, 启动时优先读 %APPDATA%\<identifier>\hotswap\ 下的覆盖
包, 没有才回退 exe 内置 dist —— 与线上 OTA 同一条路径。因此只构建前端并写进
覆盖目录 + 重启外壳即可, 不编译 Rust、不打 NSIS/便携包、不重装。

  npm run win:dev                  构建(shell 模式) + 挂载 + 重启
  npm run win:dev -- --no-build    复用现有 dist, 只挂载+重启 (~2s)
  npm run win:dev -- --clear       卸载覆盖, 回到内置前端
  npm run win:dev -- --no-launch   只改覆盖目录, 不碰外壳进程

读插件源码得到的两个硬约束 (写错会被静默丢弃或启动即回滚), 脚本已处理:
- min_binary_version 必须 == 外壳版本: 默认 DiscardOnUpgrade 在 binary > min 时
  丢弃缓存, 而安全线又要求 binary >= min, 只能取等号;
- confirmed 必须为 true: 默认 SingleLaunch 对未确认版本启动即回滚。
另: 目录名须为 seq-<数字>; sequence 取 Date.now() 让 OTA 检查认为已是最新,
避免线上更新顶掉本地版本。

README 补「Windows 本地实时预览(不打包)」章节: 用法/原理/约束表/注意事项。
This commit is contained in:
jif2.zhang
2026-10-27 15:49:39 +08:00
parent 1d800c536e
commit c460f09821
3 changed files with 217 additions and 0 deletions
+1
View File
@@ -11,6 +11,7 @@
"build:shell": "vite build --mode shell",
"build:win": "node scripts/build-windows.mjs",
"build:win:debug": "node scripts/build-windows.mjs --debug",
"win:dev": "node scripts/dev-windows-live.mjs",
"build:ota": "node scripts/build-ota.mjs",
"preview": "vite preview",
"start": "node --experimental-strip-types --no-warnings server/index.js",