docs/archives/118-desktop-auto-update-system/design.md
桌面端自动更新系统采用双版本显示设计,同时展示正式版和预览版更新信息,让用户自主选择更新路径。
┌─────────────────────────────────────────┐
│ 应用更新 │
├─────────────────────────────────────────┤
│ ┌─ 当前版本 ─────────────────────────┐ │
│ │ 当前版本: v1.2.0 │ │
│ └───────────────────────────────────┘ │
│ │
│ ┌─ 最新正式版 ─────────────────────────┐ │
│ │ 正式版 v1.2.1 [有更新] ↗ │ │
│ │ [详情] [忽略] [下载] │ │
│ └─────────────────────────────────────┘ │
│ │
│ ┌─ 最新预览版 ─────────────────────────┐ │
│ │ 预览版 v1.3.0-beta.1 [有更新] ↗ │ │
│ │ [详情] [忽略] [下载] │ │
│ └─────────────────────────────────────┘ │
│ │
├─────────────────────────────────────────┤
│ [关闭] [检查更新] │
└─────────────────────────────────────────┘
// 主进程统一管理,避免并发冲突
const checkAllVersions = async () => {
// 串行检查正式版
autoUpdater.allowPrerelease = false
const stableResult = await autoUpdater.checkForUpdates()
// 延迟后检查预览版
await new Promise(resolve => setTimeout(resolve, 1000))
autoUpdater.allowPrerelease = true
const prereleaseResult = await autoUpdater.checkForUpdates()
return { stable: stableResult, prerelease: prereleaseResult }
}
interface UpdaterState {
// 检查状态
isChecking: boolean
hasStableUpdate: boolean
hasPrereleaseUpdate: boolean
// 版本信息
currentVersion: string
stableVersion: string | null
prereleaseVersion: string | null
// 下载状态
isDownloading: boolean
downloadProgress: number
isDownloaded: boolean
// 忽略状态
isStableVersionIgnored: boolean
isPrereleaseVersionIgnored: boolean
}
设计目标:提供直观、可靠、用户友好的自动更新体验,让用户能够轻松管理应用版本更新。