mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-16 15:26:27 -04:00
优化地区判断逻辑 (#4401)
This commit is contained in:
parent
9a475c2e92
commit
fe59f495f6
@ -41,6 +41,7 @@ import org.jackhuang.hmcl.ui.construct.AdvancedListItem;
|
|||||||
import org.jackhuang.hmcl.ui.construct.ClassTitle;
|
import org.jackhuang.hmcl.ui.construct.ClassTitle;
|
||||||
import org.jackhuang.hmcl.ui.decorator.DecoratorAnimatedPage;
|
import org.jackhuang.hmcl.ui.decorator.DecoratorAnimatedPage;
|
||||||
import org.jackhuang.hmcl.ui.decorator.DecoratorPage;
|
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.io.NetworkUtils;
|
||||||
import org.jackhuang.hmcl.util.javafx.BindingMapping;
|
import org.jackhuang.hmcl.util.javafx.BindingMapping;
|
||||||
import org.jackhuang.hmcl.util.javafx.MappedObservableList;
|
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.Kernel32;
|
||||||
import org.jackhuang.hmcl.util.platform.windows.WinConstants;
|
import org.jackhuang.hmcl.util.platform.windows.WinConstants;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.util.Arrays;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import static org.jackhuang.hmcl.setting.ConfigHolder.globalConfig;
|
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);
|
static final BooleanProperty RESTRICTED = new SimpleBooleanProperty(true);
|
||||||
|
|
||||||
private static boolean isExemptedRegion() {
|
private static boolean isExemptedRegion() {
|
||||||
String zoneId = ZoneId.systemDefault().getId();
|
if ("Asia/Shanghai".equals(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))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS && NativeUtils.USE_JNA) {
|
// Check if the time zone is UTC+8
|
||||||
Kernel32 kernel32 = Kernel32.INSTANCE;
|
if (ZonedDateTime.now().getOffset().getTotalSeconds() == Duration.ofHours(8).toSeconds()) {
|
||||||
|
if ("CN".equals(LocaleUtils.SYSTEM_DEFAULT.getCountry()))
|
||||||
// https://learn.microsoft.com/windows/win32/intl/table-of-geographical-locations
|
|
||||||
if (kernel32 != null && kernel32.GetUserGeoID(WinConstants.GEOCLASS_NATION) == 45) // China
|
|
||||||
return true;
|
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)
|
if (OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS && NativeUtils.USE_JNA) {
|
||||||
// Java may not be able to resolve this name and use GMT+08:00 instead.
|
Kernel32 kernel32 = Kernel32.INSTANCE;
|
||||||
return true;
|
|
||||||
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user