From b468b9774dfd8da913b732461d6ce9ecf5e47c33 Mon Sep 17 00:00:00 2001 From: octopus_yan Date: Mon, 11 Nov 2024 00:01:32 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=89=8B=E5=8A=A8=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alistgui/viewModel/SetupViewModel.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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) {