Skip to content

feat: 启动器后台自动下载更新#6072

Open
HaoHaoLucas wants to merge 6 commits intoHMCL-dev:mainfrom
HaoHaoLucas:feature/issue-4352-background-auto-download-update
Open

feat: 启动器后台自动下载更新#6072
HaoHaoLucas wants to merge 6 commits intoHMCL-dev:mainfrom
HaoHaoLucas:feature/issue-4352-background-auto-download-update

Conversation

@HaoHaoLucas
Copy link
Copy Markdown

@HaoHaoLucas HaoHaoLucas commented May 7, 2026

Related: #4352
在设置中增加「在后台自动下载更新」开关(默认关闭)。开启后,当检测到当前版本落后于远端时,在后台将更新包下载到全局目录下的 cache/update/,完成后在界面底部展示常驻提示,用户可在方便时点击「重启以更新」完成替换。行为与 issue 中描述的「类似 VS Code」一致。

主要改动

  • 配置:Config.backgroundAutoDownloadUpdate,持久化到配置文件。
  • 触发:UpdateChecker 在 outdated 变化时调用 UpdateHandler;设置里打开开关时也会尝试触发一次。
  • 下载与缓存:UpdateHandler 将 jar 下载到 HMCL_GLOBAL_DIRECTORY/cache/update/,校验完整性,清理同目录下其它旧文件;失败时删除不完整文件。
  • 应用更新:applyStagedUpdate 走与现有更新相同的 requestUpdate / --apply-to 流程;抽取 prepareExitForUpdate 供对话框更新与缓存更新共用。
  • UI:DecoratorController.showPersistentSnackbar;Controllers.showPendingUpdateNotification 去重;设置页「更新」分组中的开关与中英文文案。
  • 修复与体验(后续 commit)
  • 设置页:更新按钮在有/无新版本时均显示;尚无远端版本信息时点击会重新请求检查并给出「正在检查更新」提示。

测试说明

image 使用`java "-Dhmcl.self_integrity_check.disable=true" "-Dhmcl.version.override=3.5.0" -jar $jar`模拟旧版本登录后,并且调整为稳定版的时候会自动在后台下载最新版本 image

目前只适配了简体繁体和英文

HaoHaoLucas and others added 6 commits May 7, 2026 01:35
Co-authored-by: Cursor <cursoragent@cursor.com>
- prepareExitForUpdate:在 JavaFX 线程上直接保存窗口状态,避免 applyStagedUpdate 死锁\n- startJava:不向子进程传递 hmcl.version.override,避免 --apply-to 后仍显示测试版本号\n- SettingsPage:更新按钮始终可见;无远端版本缓存时触发重新检查并提示

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant