自动更新
Tauri Updater Plugin 与 CDN 端点的集成流程
自动更新
WinCode 的桌面自动更新基于 Tauri Updater Plugin 实现,由 Rust 侧 state.updater 驱动、前端 AboutTab 与 UpdateNotification 组件交互。更新包与 manifest 通过内网 CDN wincode.winning.com.cn 分发。

状态机
更新状态 UpdateStatus.state 按以下顺序流转:
upToDate ──check──▶ available ──download──▶ downloading ──▶ downloaded ──install──▶ installing ──▶ upToDate
│ │
└──── error ◀──────┴──────────────────────────────────────────────────────────┘开发模式下返回 unavailable,附带 unavailableReason,界面不展示错误。
前端 API
src/services/modules/updater.ts 封装四个命令:
updateStatus() // 查询当前状态
updateCheck() // 向 CDN 请求 manifest
updateDownload() // 下载更新包
updateInstall({ confirmRestart }) // 安装并(可选)确认重启所有命令通过 call<UpdateStatus>(...) 走 Tauri invoke,对应 Rust 侧 update_status / update_check / update_download / update_install 四个 #[tauri::command]。
下载进度
通过 onUpdateProgress(handler) 监听事件 update://progress,事件负载 UpdateProgress 包含:
downloadedBytes— 已下载字节totalBytes— 总字节bytesPerSecond— 下载速度
AboutTab 中的 ProgressBar 据此渲染进度条与 xx.x MB / xx.x MB · xx.x MB/s 文本。
CDN 端点
发版脚本写入 manifest 到 release-manifest/<target>/<arch>/<version>.json,上传到 CDN 后,客户端检查 URL:
https://wincode.winning.com.cn/api/updater/check/<target>/<arch>/<currentVersion>其中:
target—darwin-aarch64/darwin-x86_64/windows-x86_64/linux-x86_64arch—aarch64/x86_64currentVersion— 当前版本号,用于比对
返回的 manifest 结构:
{
"version": "2.3.11",
"target": "darwin-aarch64",
"arch": "aarch64",
"notes": "## 新功能\n- ...",
"pub_date": "2026-06-20T10:00:00Z",
"url": "https://wincode.winning.com.cn/release/Win-Code.app.tar.gz",
"signature": "dGVzdHNpZw=="
}UpdateNotification 气泡
UpdateNotification 是全局浮动提示组件,根据状态弹出"可更新至 x.y.z"的按钮;点击跳转到 About Tab 触发下载/安装流程。
密钥与签名
更新包签名由 Tauri Updater 管理。scripts/sign-build.mjs 在构建时自动注入 ~/.tauri/wincode.key 与 wincode.key.password,签名写入每个 bundle 的 .sig 文件,客户端用 tauri.conf.json 中的 pubkey 校验。