From fe59f495f6812fbfb22401739e1ad5d0aa3e004d Mon Sep 17 00:00:00 2001 From: Glavo Date: Sat, 6 Sep 2025 15:40:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9C=B0=E5=8C=BA=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E9=80=BB=E8=BE=91=20(#4401)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmcl/ui/account/AccountListPage.java | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountListPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountListPage.java index c2e5d1547..bfaafc74a 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountListPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountListPage.java @@ -41,6 +41,7 @@ import org.jackhuang.hmcl.ui.construct.AdvancedListItem; import org.jackhuang.hmcl.ui.construct.ClassTitle; import org.jackhuang.hmcl.ui.decorator.DecoratorAnimatedPage; import org.jackhuang.hmcl.ui.decorator.DecoratorPage; +import org.jackhuang.hmcl.util.i18n.LocaleUtils; import org.jackhuang.hmcl.util.io.NetworkUtils; import org.jackhuang.hmcl.util.javafx.BindingMapping; import org.jackhuang.hmcl.util.javafx.MappedObservableList; @@ -49,8 +50,9 @@ import org.jackhuang.hmcl.util.platform.OperatingSystem; import org.jackhuang.hmcl.util.platform.windows.Kernel32; import org.jackhuang.hmcl.util.platform.windows.WinConstants; +import java.time.Duration; import java.time.ZoneId; -import java.util.Arrays; +import java.time.ZonedDateTime; import java.util.Locale; import static org.jackhuang.hmcl.setting.ConfigHolder.globalConfig; @@ -63,27 +65,22 @@ public final class AccountListPage extends DecoratorAnimatedPage implements Deco static final BooleanProperty RESTRICTED = new SimpleBooleanProperty(true); private static boolean isExemptedRegion() { - String zoneId = ZoneId.systemDefault().getId(); - if (Arrays.asList( - "Asia/Shanghai", - // Although Asia/Beijing is not a legal name, Deepin uses it - "Asia/Beijing", - "Asia/Chongqing", - "Asia/Chungking", - "Asia/Harbin" - ).contains(zoneId)) + if ("Asia/Shanghai".equals(ZoneId.systemDefault().getId())) return true; - if (OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS && NativeUtils.USE_JNA) { - Kernel32 kernel32 = Kernel32.INSTANCE; - - // https://learn.microsoft.com/windows/win32/intl/table-of-geographical-locations - if (kernel32 != null && kernel32.GetUserGeoID(WinConstants.GEOCLASS_NATION) == 45) // China + // Check if the time zone is UTC+8 + if (ZonedDateTime.now().getOffset().getTotalSeconds() == Duration.ofHours(8).toSeconds()) { + if ("CN".equals(LocaleUtils.SYSTEM_DEFAULT.getCountry())) return true; - } else if (OperatingSystem.CURRENT_OS == OperatingSystem.LINUX && "GMT+08:00".equals(zoneId)) - // Some Linux distributions may use invalid time zone ids (e.g., Asia/Beijing) - // Java may not be able to resolve this name and use GMT+08:00 instead. - return true; + + if (OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS && NativeUtils.USE_JNA) { + Kernel32 kernel32 = Kernel32.INSTANCE; + + // https://learn.microsoft.com/windows/win32/intl/table-of-geographical-locations + if (kernel32 != null && kernel32.GetUserGeoID(WinConstants.GEOCLASS_NATION) == 45) // China + return true; + } + } return false; }