Files
image-workbench-desktop/docs/DESKTOP_UPDATE.md
T
qiqi d0c3edf352
Verify Web / e2e (Playwright) (push) Skipped
Verify Web / gate (build · lint · unit · facts) (push) Canceled after 0s
feat(settings): 通用页加「版本与更新」+ 在线更新方案文档(A/B/C 三方案与配置清单)
2026-11-17 09:17:05 +08:00

83 lines
2.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.
# 桌面版在线更新:方案与落地清单(2026-11-17)
> 现状:设置 → 通用 已有「版本与更新」区块(版本号 + 「检查更新」按钮)。
> 按钮会检测 `window.__TAURI__.updater`;插件装上并配好更新源后自动生效,现在点它只会提示"尚未启用"。
## 一、三种方案
| 方案 | 用户体验 | 需要什么 | 适合 |
|---|---|---|---|
| **A. Tauri 官方 updater** | 应用内检查→下载→自动替换→重启 | 更新源(HTTPS 静态) + 一对签名密钥 + 发布流程 | 要发给别人 |
| B. 手动下载 | 去网盘/Release 下新包替换 | 一个能放包的地方 | 自用、低频 |
| C. 只提示(自研检查) | 提示"有新版本"+下载链接,不自动装 | 一个 version.json | 轻量折中 |
**建议**:现在自用 → 先做 **C**(零密钥、能及时知道);要发给别人再升 A。
## 二、A 方案要素
### 1. 依赖
```bash
# Cargo.toml: tauri-plugin-updater = "2"
npm i @tauri-apps/plugin-updater
```
lib.rs: `.plugin(tauri_plugin_updater::Builder::new().build())`;capabilities 加 `"updater:default"`
### 2. 签名密钥(一次生成,永久保管)
```bash
npx tauri signer generate -w ~/.tauri/image-workbench.key
```
私钥绝不进仓库;公钥写进 `plugins.updater.pubkey`。
**丢了私钥 = 老用户永远收不到更新。**
### 3. 配置
```json
{
"plugins": { "updater": {
"pubkey": "<公钥>",
"endpoints": ["https://<域名>/image-workbench/latest.json"]
} },
"bundle": { "createUpdaterArtifacts": true }
}
```
### 4. 清单 latest.json
```json
{
"version": "3.25.0",
"notes": "…",
"pub_date": "2026-11-17T10:00:00Z",
"platforms": {
"darwin-aarch64": { "signature": "<sig>", "url": "…app.tar.gz" },
"windows-x86_64": { "signature": "<sig>", "url": "…nsis.zip" }
}
}
```
### 5. 构建带签名
```bash
TAURI_SIGNING_PRIVATE_KEY=... TAURI_SIGNING_PRIVATE_KEY_PASSWORD=... npm run app:build
```
产出 `*.app.tar.gz(.sig)` / `*.nsis.zip(.sig)`,与清单一起上传。
### 6. 托管选择
| 位置 | 可行 | 注意 |
|---|---|---|
| GitHub Releases | ✅ | 私有库资产需匿名可读 |
| Cloudflare R2/Pages | ✅ | 公开读 + HTTPS |
| 飞牛 NAS / Gitea | ⚠️ | 必须公网 HTTPS 且免鉴权;私有库要 token ⇒ 不可用 |
## 三、现在就该定的事
1. 版本号三处一致(tauri.conf / Cargo / package.json),每次发布递增
2. macOS 要出 aarch64 + x64 两套;Windows 出 x64
3. 私钥本机签还是 CI 签
## 四、C 方案(建议先做)
1. 静态放 `version.json`:`{version, notes, url}`
2. 「检查更新」改成 HTTP GET 比对版本,有新版给下载链接
3. 零密钥、零签名、不影响安装包
## 五、现状
- ✅ 通用页已显示版本号 + 检查更新按钮
- ⬜ 待你定:A 还是 C
- 提醒:未签名的 macOS 应用即使更新成功,首次打开仍有 Gatekeeper 提示;要消除需 Apple Developer ID($99/年),不影响自用。