(silent: boolean = true)
| 30 | * @returns 是否发现新版本 |
| 31 | */ |
| 32 | export async function checkForUpdate(silent: boolean = true): Promise<boolean> { |
| 33 | // 避免重复检查 |
| 34 | if (isUpdating) { |
| 35 | return false |
| 36 | } |
| 37 | |
| 38 | try { |
| 39 | const update = await check() |
| 40 | |
| 41 | if (!update) { |
| 42 | // 无更新 |
| 43 | if (!silent) { |
| 44 | Modal.success({ |
| 45 | title: t('update_check_complete'), |
| 46 | content: t('already_latest_version'), |
| 47 | okText: t('ok'), |
| 48 | }) |
| 49 | } |
| 50 | return false |
| 51 | } |
| 52 | |
| 53 | // 有新版本,显示更新对话框 |
| 54 | showUpdateDialog(update) |
| 55 | return true |
| 56 | } catch (error) { |
| 57 | console.error('Check update failed:', error) |
| 58 | if (!silent) { |
| 59 | Modal.error({ |
| 60 | title: t('check_update_failed'), |
| 61 | content: String(error), |
| 62 | okText: t('ok'), |
| 63 | }) |
| 64 | } |
| 65 | return false |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | function showUpdateDialog(update: UpdateInfo) { |
| 70 | let downloaded = 0 |
no test coverage detected