diff --git a/gui/src/main/java/cn/octopusyan/alistgui/viewModel/SetupViewModel.java b/gui/src/main/java/cn/octopusyan/alistgui/viewModel/SetupViewModel.java index c910fcc..eaf8df5 100644 --- a/gui/src/main/java/cn/octopusyan/alistgui/viewModel/SetupViewModel.java +++ b/gui/src/main/java/cn/octopusyan/alistgui/viewModel/SetupViewModel.java @@ -65,8 +65,14 @@ public class SetupViewModel extends BaseViewModel { proxySetup.addListener((_, _, newValue) -> ConfigManager.proxySetup(newValue)); proxyTestUrl.addListener((_, _, newValue) -> ConfigManager.proxyTestUrl(newValue)); proxyHost.addListener((_, _, newValue) -> ConfigManager.proxyHost(newValue)); - proxyPort.addListener((_, _, newValue) -> ConfigManager.proxyPort(newValue)); - language.addListener((_, _, newValue) -> Context.setLanguage(newValue)); + proxyHost.addListener((_, _, newValue) -> { + ConfigManager.proxyHost(newValue); + setProxy(); + }); + proxyPort.addListener((_, _, newValue) -> { + ConfigManager.proxyPort(newValue); + setProxy(); + }); } public ObjectProperty themeProperty() { @@ -123,6 +129,14 @@ public class SetupViewModel extends BaseViewModel { }); } + private void setProxy() { + ConfigManager.checkProxy((success, _) -> { + if (!success) return; + + HttpUtil.getInstance().proxy(ConfigManager.proxySetup(), ConfigManager.getProxyInfo()); + }); + } + private static ProxyCheckTask getProxyCheckTask(String checkUrl) { var task = new ProxyCheckTask(checkUrl); task.onListen(new TaskListener(task) {