chore: 手动代理修改配置

This commit is contained in:
octopus_yan 2024-11-11 00:01:32 +08:00
parent 17d21fdc03
commit b468b9774d

View File

@ -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<Theme> 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) {