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

View File

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