Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java
Original file line number Diff line number Diff line change
Expand Up @@ -625,14 +625,15 @@ public static void showToast(String content) {
public static void onHyperlinkAction(String href) {
if (href.startsWith("hmcl://")) {
switch (href) {
case "hmcl://settings/feedback":
case "hmcl://settings/feedback" -> {
Controllers.getSettingsPage().showFeedback();
Controllers.navigate(Controllers.getSettingsPage());
break;
case "hmcl://game/launch":
}
case "hmcl://game/launch" -> {
Profile profile = Profiles.getSelectedProfile();
Versions.launch(profile, profile.getSelectedVersion(), LauncherHelper::setKeep);
break;
}
case "hmcl://update/switch-channel/stable" -> getRootPage().getMainPage().onSwitchToStableChannel();
}
} else {
FXUtils.openLink(href);
Expand Down
11 changes: 11 additions & 0 deletions HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import org.jackhuang.hmcl.ui.versions.GameListPopupMenu;
import org.jackhuang.hmcl.ui.versions.Versions;
import org.jackhuang.hmcl.upgrade.RemoteVersion;
import org.jackhuang.hmcl.upgrade.UpdateChannel;
import org.jackhuang.hmcl.upgrade.UpdateChecker;
import org.jackhuang.hmcl.upgrade.UpdateHandler;
import org.jackhuang.hmcl.util.*;
Expand Down Expand Up @@ -368,6 +369,16 @@ private void closeUpdateBubble() {
showUpdate.set(false);
}

public void onSwitchToStableChannel() {
Controllers.confirm(i18n("update.switch_to_stable.confirm"), i18n("update.switch_to_stable.title"), () -> {
UpdateChecker.requestCheckUpdate(UpdateChannel.STABLE, config().acceptPreviewUpdateProperty().get(), target -> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

在切换到稳定通道时,建议将 preview 参数硬编码为 false。用户点击“切换至稳定版”通常是为了获取当前的正式稳定版本。如果使用全局的 acceptPreviewUpdate 设置(在开发版/预览版中通常为 true),可能会导致请求 stable-preview 通道,如果服务器没有该通道则可能无法获取到预期的更新。

Suggested change
UpdateChecker.requestCheckUpdate(UpdateChannel.STABLE, config().acceptPreviewUpdateProperty().get(), target -> {
UpdateChecker.requestCheckUpdate(UpdateChannel.STABLE, false, target -> {

if (target != null) {
UpdateHandler.updateFrom(target);
}
});
}, null);
}

@Override
public ReadOnlyObjectWrapper<State> stateProperty() {
return state;
Expand Down
11 changes: 11 additions & 0 deletions HMCL/src/main/java/org/jackhuang/hmcl/upgrade/UpdateChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
import org.jackhuang.hmcl.Metadata;
import org.jackhuang.hmcl.util.io.NetworkUtils;
import org.jackhuang.hmcl.util.versioning.VersionNumber;
import org.jetbrains.annotations.Nullable;

import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.function.Consumer;

import static org.jackhuang.hmcl.setting.ConfigHolder.config;
import static org.jackhuang.hmcl.util.Lang.*;
Expand Down Expand Up @@ -102,6 +104,11 @@ private static boolean isDevelopmentVersion(String version) {
}

public static void requestCheckUpdate(UpdateChannel channel, boolean preview) {
requestCheckUpdate(channel, preview, null);
}

public static void requestCheckUpdate(UpdateChannel channel, boolean preview,
@Nullable Consumer<@Nullable RemoteVersion> callback) {
Platform.runLater(() -> {
if (isCheckingUpdate())
return;
Comment on lines 113 to 114
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

如果当前已经有一个更新检查正在进行中(isCheckingUpdate()true),该方法会直接返回,导致传入的 callback 永远不会被调用。这会使得调用方(如 MainPage 中的切换通道逻辑)处于等待状态且没有任何反馈。建议在这种情况下也调用 callback(例如传入 null)或者告知调用方请求被跳过。

Suggested change
if (isCheckingUpdate())
return;
if (isCheckingUpdate()) {
if (callback != null) callback.accept(null);
return;
}

Expand All @@ -122,6 +129,10 @@ public static void requestCheckUpdate(UpdateChannel channel, boolean preview) {
if (finalResult != null) {
latestVersion.set(finalResult);
}

if (callback != null) {
callback.accept(finalResult);
}
});
}, "Update Checker", true);
});
Expand Down
6 changes: 4 additions & 2 deletions HMCL/src/main/resources/assets/lang/I18N.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1632,14 +1632,14 @@ update=Update
update.accept=Update
update.changelog=Changelog
update.channel.dev=Beta
update.channel.dev.hint=You are currently using a Beta channel build of the launcher. While it may include some extra features, it is also sometimes less stable than the Stable channel builds.\n\
update.channel.dev.hint=You are currently using a Beta channel build of the launcher. While it may include some extra features, it is also sometimes less stable than the Stable channel builds. <a href="hmcl://update/switch-channel/stable">Switch to Stable channel</a>\n\
\n\
If you encounter any bugs or problems, please submit feedback via the channels provided on the <a href="hmcl://settings/feedback">Feedback</a> page.\n\
\n\
Follow <a href="https://space.bilibili.com/1445341">@huanghongxun</a> on Bilibili to stay up to date on important HMCL news, or <a href="https://space.bilibili.com/20314891">@Glavo</a> to learn about HMCL development progress.
update.channel.dev.title=Beta Channel Notice
update.channel.nightly=Nightly
update.channel.nightly.hint=You are currently using a Nightly channel build of the launcher. While it may include some extra features, it is also always less stable than the other channel builds.\n\
update.channel.nightly.hint=You are currently using a Nightly channel build of the launcher. While it may include some extra features, it is also always less stable than the other channel builds. <a href="hmcl://update/switch-channel/stable">Switch to Stable channel</a>\n\
\n\
If you encounter any bugs or problems, please submit feedback via the channels provided on the <a href="hmcl://settings/feedback">Feedback</a> page.\n\
\n\
Expand All @@ -1658,6 +1658,8 @@ update.note.stable=Suitable for users who prioritize software stability.\nNew fe
update.note.dev=Suitable for users who want to experience new features first.\nThe development version includes the latest features and bug fixes,\nbut may also have more issues due to insufficient testing.
update.latest=This is the latest version
update.no_browser=Cannot open in system browser. But we copied the link to your clipboard, and you can open it manually.
update.switch_to_stable.confirm=Want to switch to the stable channel of HMCL?\nClick "Yes" to download and install the latest stable version of HMCL.
update.switch_to_stable.title=Switch to Stable Channel
update.tooltip=Update
update.preview=Preview HMCL releases early
update.preview.subtitle=Enable this option to receive new versions of HMCL early for testing before their official release.
Expand Down
6 changes: 4 additions & 2 deletions HMCL/src/main/resources/assets/lang/I18N_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1422,12 +1422,12 @@ update=啟動器更新
update.accept=更新
update.changelog=更新日誌
update.channel.dev=開發版
update.channel.dev.hint=你正在使用 HMCL 開發版。開發版包含一些未在穩定版中包含的測試性功能,僅用於體驗新功能。開發版功能未受充分驗證,使用起來可能不穩定!\n\
update.channel.dev.hint=你正在使用 HMCL 開發版。開發版包含一些未在穩定版中包含的測試性功能,僅用於體驗新功能。開發版功能未受充分驗證,使用起來可能不穩定!<a href="hmcl://update/switch-channel/stable">切換至穩定管道</a>\n\
\n\
如果你遇到了使用問題,可以透過設定中 <a href="hmcl://settings/feedback">回報頁面</a> 提供的管道進行回報。歡迎關注 Bilibili <a href="https://space.bilibili.com/1445341">@huanghongxun</a> 以關注 HMCL 的重要動態,或關注 <a href="https://space.bilibili.com/20314891">@Glavo</a> 以瞭解 HMCL 的開發進展。
update.channel.dev.title=開發版提示
update.channel.nightly=預覽版
update.channel.nightly.hint=你正在使用 HMCL 預覽版。預覽版更新較為頻繁,包含一些未在穩定版和開發版中包含的測試性功能,僅用於體驗新功能。預覽版功能未受充分驗證,使用起來可能不穩定!\n\
update.channel.nightly.hint=你正在使用 HMCL 預覽版。預覽版更新較為頻繁,包含一些未在穩定版和開發版中包含的測試性功能,僅用於體驗新功能。預覽版功能未受充分驗證,使用起來可能不穩定!<a href="hmcl://update/switch-channel/stable">切換至穩定管道</a>\n\
\n\
如果你遇到了使用問題,可以透過設定中 <a href="hmcl://settings/feedback">回報頁面</a> 提供的管道進行回報。歡迎關注 Bilibili <a href="https://space.bilibili.com/1445341">@huanghongxun</a> 以關注 HMCL 的重要動態,或關注 <a href="https://space.bilibili.com/20314891">@Glavo</a> 以瞭解 HMCL 的開發進展。
update.channel.nightly.title=預覽版提示
Expand All @@ -1444,6 +1444,8 @@ update.note.stable=適合優先追求軟體穩定性的使用者使用。\n新
update.note.dev=適合希望優先體驗新功能的使用者使用。\n開發版會包含最新功能和錯誤修復,但未經充分測試,可能會存在更多問題。
update.latest=目前版本為最新版本
update.no_browser=無法開啟瀏覽器。網址已經複製到剪貼簿了,你可以手動複製網址開啟頁面。
update.switch_to_stable.confirm=希望切換至穩定管道嗎?\n這將會下載並安裝最新的 HMCL 穩定版本。
update.switch_to_stable.title=切換至穩定管道
update.tooltip=更新
update.preview=提前測試 HMCL 預覽版本
update.preview.subtitle=啟用此選項,你將可以提前取得 HMCL 的新版本,以便在正式發布前進行測試。
Expand Down
6 changes: 4 additions & 2 deletions HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1427,12 +1427,12 @@ update=启动器更新
update.accept=更新
update.changelog=更新日志
update.channel.dev=开发版
update.channel.dev.hint=你正在使用 HMCL 开发版。开发版包含一些未在稳定版中包含的测试性功能,仅用于体验新功能。开发版功能未受充分验证,使用起来可能不稳定!<a href="https://hmcl.huangyuhui.net/download">下载稳定版</a>\n\
update.channel.dev.hint=你正在使用 HMCL 开发版。开发版包含一些未在稳定版中包含的测试性功能,仅用于体验新功能。开发版功能未受充分验证,使用起来可能不稳定!<a href="hmcl://update/switch-channel/stable">切换至稳定版</a>\n\
\n\
如果你使用时遇到了问题,可以通过设置中<a href="hmcl://settings/feedback">反馈页面</a>提供的渠道进行反馈。欢迎关注 B 站账号 <a href="https://space.bilibili.com/1445341">@huanghongxun</a> 以关注 HMCL 的重要动态,或关注 <a href="https://space.bilibili.com/20314891">@Glavo</a> 以了解 HMCL 的开发进展。
update.channel.dev.title=开发版提示
update.channel.nightly=预览版
update.channel.nightly.hint=你正在使用 HMCL 预览版。预览版更新较为频繁,包含一些未在稳定版和开发版中包含的测试性功能,仅用于体验新功能。预览版功能未受充分验证,使用起来可能不稳定!<a href="https://hmcl.huangyuhui.net/download">下载稳定版</a>\n\
update.channel.nightly.hint=你正在使用 HMCL 预览版。预览版更新较为频繁,包含一些未在稳定版和开发版中包含的测试性功能,仅用于体验新功能。预览版功能未受充分验证,使用起来可能不稳定!<a href="hmcl://update/switch-channel/stable">切换至稳定版</a>\n\
\n\
如果你使用时遇到了问题,可以通过设置中<a href="hmcl://settings/feedback">反馈页面</a>提供的渠道进行反馈。欢迎关注 B 站账号 <a href="https://space.bilibili.com/1445341">@huanghongxun</a> 以关注 HMCL 的重要动态,或关注 <a href="https://space.bilibili.com/20314891">@Glavo</a> 以了解 HMCL 的开发进展。
update.channel.nightly.title=预览版提示
Expand All @@ -1449,6 +1449,8 @@ update.note.stable=适合优先追求软件稳定性的用户使用。\n新功
update.note.dev=适合希望优先体验新功能的用户使用。\n包含最新功能和错误修复,但未经充分测试,可能会存在更多问题。
update.latest=当前版本为最新版本
update.no_browser=无法打开浏览器。网址已经复制到剪贴板,你可以手动粘贴网址打开页面。
update.switch_to_stable.confirm=是否切换至稳定版?\n这将会下载并安装最新的 HMCL 稳定版本。
update.switch_to_stable.title=切换至稳定版
update.tooltip=更新
update.preview=提前预览 HMCL 版本
update.preview.subtitle=启用此选项,你将可以提前获取 HMCL 的新版本,以便在正式发布前进行测试。
Expand Down