()
| 17 | * 返回检查结果,由调用者决定是否安装 |
| 18 | */ |
| 19 | export async function checkForUpdates(): Promise<UpdateCheckResult> { |
| 20 | try { |
| 21 | const update = await check(); |
| 22 | |
| 23 | if (update?.available) { |
| 24 | pendingUpdate = update; |
| 25 | return { |
| 26 | available: true, |
| 27 | version: update.version, |
| 28 | currentVersion: update.currentVersion |
| 29 | }; |
| 30 | } else { |
| 31 | pendingUpdate = null; |
| 32 | return { available: false }; |
| 33 | } |
| 34 | } catch (error) { |
| 35 | console.error('检查更新失败:', error); |
| 36 | pendingUpdate = null; |
| 37 | return { |
| 38 | available: false, |
| 39 | error: error instanceof Error ? error.message : '检查更新失败' |
| 40 | }; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * 安装待处理的更新 |
no test coverage detected