From ffc3cbb4a937af13aad36dc29adfd4229160583f Mon Sep 17 00:00:00 2001 From: Misaka Date: Tue, 24 Mar 2026 21:43:03 +0800 Subject: [PATCH] feat: implement background update download without blocking user login - Change update check and download to async execution, allowing immediate app entry for User users - Updates run in background, showing update prompt when download completes - Optimize login flow experience, eliminating blocking time caused by update downloads - Add release notes for version 1.5.1 Co-Authored-By: Claude Sonnet 4.6 --- docs/releases/1.5.1.md | 7 +++++++ src/main/services/update/update-service.ts | 15 ++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 docs/releases/1.5.1.md diff --git a/docs/releases/1.5.1.md b/docs/releases/1.5.1.md new file mode 100644 index 0000000..666d0c6 --- /dev/null +++ b/docs/releases/1.5.1.md @@ -0,0 +1,7 @@ +# 1.5.1 + +## 体验优化 + +- User 用户登录后立即进入应用,更新检查和下载在后台运行。 +- 下载完成后自动显示更新提示,整个过程对用户透明。 +- 优化登录流程体验,消除更新下载导致的阻塞时间。 diff --git a/src/main/services/update/update-service.ts b/src/main/services/update/update-service.ts index 2bcf94a..fb775a8 100644 --- a/src/main/services/update/update-service.ts +++ b/src/main/services/update/update-service.ts @@ -124,7 +124,12 @@ export class UpdateService { return } - await this.checkForUpdates() + // 启动异步更新检查,不阻塞登录流程 + void this.checkForUpdates().catch((error) => { + log.warn('Async update check failed', { + error: error instanceof Error ? error.message : String(error) + }) + }) this.startPolling() } @@ -149,16 +154,16 @@ export class UpdateService { this.publishStatus(nextStatus) if (nextStatus.phase === 'available' && nextStatus.recommendedRelease) { - try { - await this.downloadRelease(nextStatus.recommendedRelease) - } catch (error) { + // 异步下载,不阻塞更新检查流程 + void this.downloadRelease(nextStatus.recommendedRelease).catch((error) => { const message = error instanceof Error ? error.message : '下载更新失败' + log.warn('Async update download failed', { error: message }) this.publishStatus({ phase: 'error', error: message, message }) - } + }) } } else if (currentUserType === 'Admin') { this.publishStatus(this.catalogService.resolveAdminStatus(this.status, this.catalog))