新增: 应用内版本更新与自动升级全链路

后端 update.rs: app_check_update(拉 latest.json+ed25519 签名校验) /
app_download_install_update / prefs 读写 / mark_checked / mark_notified 五命令,
lib.rs 注册;tauri.conf updater 段(endpoints=app.1216.top/download/devflow/latest.json
+ pubkey + createUpdaterArtifacts) + tauri-plugin-updater 依赖 + capabilities 权限。

前端 UpdateBadge.vue(顶栏徽章+下拉) / useUpdateCheck.ts(检查/下载/安装状态机) /
AboutPanel.vue(设置页关于面板) + AppLayout 接线 + SettingsNav/searchIndex 索引 +
i18n zh/en settings 键。

运维 scripts/publish-release.ps1(发版) + swap-install.ps1(换装校验) +
设计文档 版本更新与自动升级-设计-2026-10-09.md。

验收: cargo check -p devflow EXIT 0 + vue-tsc EXIT 0 + build EXIT 0。
This commit is contained in:
lxy
2026-10-09 22:53:14 +08:00
parent c70faa7bb8
commit a8c92e9619
27 changed files with 2021 additions and 24 deletions
+46
View File
@@ -21,6 +21,52 @@ export const settingsApi = {
return invoke<string>('get_data_dir')
},
/** 获取应用版本信息(编译期注入:version/build_time/git_hash) */
getVersion(): Promise<{ version: string; build_time: string; git_hash: string }> {
return invoke<{ version: string; build_time: string; git_hash: string }>('app_get_version')
},
/** B2 检查更新:拉远端 latest.json,返回是否有新版(网络失败抛错,不谎报已是最新) */
checkUpdate(): Promise<{
has_update: boolean
version: string | null
notes: string | null
date: string | null
current_version: string
}> {
return invoke('app_check_update')
},
/** B2 读自动检查偏好 */
getUpdatePrefs(): Promise<{
auto_check: boolean
interval_minutes: number
last_check: string
notified_version: string
}> {
return invoke('app_update_get_prefs')
},
/** B2 写自动检查偏好 */
setUpdatePrefs(autoCheck: boolean, intervalMinutes: number): Promise<void> {
return invoke('app_update_set_prefs', { autoCheck, intervalMinutes })
},
/** B2 记录一次检查时间戳(节流用) */
markUpdateChecked(timestamp: string): Promise<void> {
return invoke('app_update_mark_checked', { timestamp })
},
/** B2 记录已提示版本号(同版本只提示一次) */
markUpdateNotified(version: string): Promise<void> {
return invoke('app_update_mark_notified', { version })
},
/** B3 下载并安装更新(进度经 app-update-progress 事件流;成功即自动重启) */
downloadAndInstallUpdate(): Promise<void> {
return invoke('app_download_install_update')
},
/** 取全部 key/value(启动时一次性拉回恢复偏好) */
getAll(): Promise<Record<string, string>> {
return invoke<Record<string, string>>('settings_get_all')