chore: 代理设置、删除依赖

This commit is contained in:
octopus_yan 2024-09-08 12:10:12 +08:00
parent f18ff10c92
commit 8588ad8c47
2 changed files with 27 additions and 19 deletions

22
pom.xml
View File

@ -122,7 +122,7 @@
<version>${jackson.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.kordamp.ikonli/ikonli-javafx -->
<!-- https://kordamp.org/ikonli/ -->
<dependency>
<groupId>org.kordamp.ikonli</groupId>
<artifactId>ikonli-javafx</artifactId>
@ -133,11 +133,6 @@
<artifactId>ikonli-fontawesome-pack</artifactId>
<version>${ikonli.version}</version>
</dependency>
<dependency>
<groupId>org.kordamp.ikonli</groupId>
<artifactId>ikonli-coreui-pack</artifactId>
<version>${ikonli.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq</groupId>
<artifactId>emoji</artifactId>
@ -173,6 +168,7 @@
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@ -192,6 +188,15 @@
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<argLine>--enable-preview</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
@ -247,8 +252,11 @@
<!-- Default configuration for running with: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>cn.octopusyan.alistgui/cn.octopusyan.alistgui.AppLauncher</mainClass>
<launcher>launcher</launcher>
<mainClass>cn.octopusyan.alistgui/cn.octopusyan.alistgui.AppLauncher</mainClass>
<options>
<option>--enable-preview</option>
</options>
<jlinkZipName>app</jlinkZipName>
<jlinkImageName>app</jlinkImageName>
<noManPages>true</noManPages>

View File

@ -20,6 +20,7 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ProxySelector;
import java.net.http.HttpClient;
import java.util.Objects;
public class Application extends javafx.application.Application {
@ -36,13 +37,11 @@ public class Application extends javafx.application.Application {
// http请求工具初始化
HttpConfig httpConfig = new HttpConfig();
// 加载代理设置
if (!ProxySetup.NO_PROXY.equals(ConfigManager.proxySetup())) {
// 系统代理
if (ProxySetup.SYSTEM.equals(ConfigManager.proxySetup())) {
httpConfig.setProxySelector(ProxySelector.getDefault());
}
// 自定义代理
if (ProxySetup.MANUAL.equals(ConfigManager.proxySetup()) && ConfigManager.hasProxy()) {
switch (ConfigManager.proxySetup()) {
case NO_PROXY -> httpConfig.setProxySelector(HttpClient.Builder.NO_PROXY);
case SYSTEM -> httpConfig.setProxySelector(ProxySelector.getDefault());
case MANUAL -> {
if(ConfigManager.hasProxy()) {
InetSocketAddress unresolved = InetSocketAddress.createUnresolved(
Objects.requireNonNull(ConfigManager.proxyHost()),
ConfigManager.getProxyPort()
@ -50,6 +49,7 @@ public class Application extends javafx.application.Application {
httpConfig.setProxySelector(ProxySelector.of(unresolved));
}
}
}
httpConfig.setConnectTimeout(10);
HttpUtil.init(httpConfig);
}