From fc68029adc50f08fe4aa6499cfb4f6fa585db35b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=AB=E4=B9=90=E5=87=A4=E7=88=AA=E7=8E=8B?= <165921128+KSSJW@users.noreply.github.com> Date: Sun, 25 Oct 2026 21:32:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B8=AE=E5=8A=A9=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BC=82=E5=B8=B8=E6=8F=90=E7=A4=BA=E5=8F=8A?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E5=8A=9F=E8=83=BD=20(#7047)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jackhuang/hmcl/ui/main/HelpPage.java | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/HelpPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/HelpPage.java index ca2c698107..888c1b67a5 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/HelpPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/HelpPage.java @@ -18,6 +18,8 @@ package org.jackhuang.hmcl.ui.main; import com.google.gson.annotations.SerializedName; + +import javafx.scene.Node; import javafx.scene.control.ScrollPane; import javafx.scene.layout.VBox; import org.jackhuang.hmcl.Metadata; @@ -30,10 +32,12 @@ import org.jackhuang.hmcl.ui.construct.SpinnerPane; import org.jackhuang.hmcl.util.gson.JsonSerializable; import org.jackhuang.hmcl.util.io.HttpRequest; +import java.util.ArrayList; import java.util.List; import static org.jackhuang.hmcl.util.gson.JsonUtils.listTypeOf; import static org.jackhuang.hmcl.util.i18n.I18n.i18n; +import static org.jackhuang.hmcl.util.logging.Logger.LOG; public class HelpPage extends SpinnerPane { @@ -62,7 +66,16 @@ public class HelpPage extends SpinnerPane { private void loadHelp() { showSpinner(); Task.supplyAsync(() -> HttpRequest.GET(Metadata.DOCS_URL + "/index.json").getJson(listTypeOf(HelpCategory.class))) - .thenAcceptAsync(Schedulers.javafx(), helpCategories -> { + .whenComplete(Schedulers.javafx(), (helpCategories, exception) -> { + if (exception != null) { + LOG.warning("Failed to load help page: ", exception); + showLoadFailure(); + return; + } + + try { + List nodes = new ArrayList<>(); + for (HelpCategory category : helpCategories) { ComponentList categoryPane = new ComponentList(); @@ -75,11 +88,24 @@ public class HelpPage extends SpinnerPane { categoryPane.getContent().add(item); } - content.getChildren().add(ComponentList.createComponentListTitle(category.title())); - content.getChildren().add(categoryPane); + nodes.add(ComponentList.createComponentListTitle(category.title())); + nodes.add(categoryPane); } + + content.getChildren().addAll(nodes); + hideSpinner(); - }).start(); + } catch (Exception e) { + LOG.warning("Failed to display help page: ", e); + showLoadFailure(); + } + }).start(); + } + + private void showLoadFailure() { + setFailedReason(i18n("download.failed.refresh")); + setOnFailedAction(e -> loadHelp()); + setLoading(false); } @JsonSerializable