Compare commits
No commits in common. "a8db7cbf8863207d94237c0097825a3ae5060b35" and "4dc13bb8f1bd65deeb8b72a788b9f9d072a36499" have entirely different histories.
a8db7cbf88
...
4dc13bb8f1
1
.gitignore
vendored
@ -8,7 +8,6 @@ target/
|
||||
!**/src/test/**/target/
|
||||
/bin/
|
||||
gui.yaml
|
||||
upgrade.exe
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
### 截图
|
||||
|
||||
<details open>
|
||||
<details>
|
||||
<summary> 主界面 </summary>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/909ac6ad-0021-47d7-a75c-7fb6505e8c15">
|
||||
@ -28,7 +28,7 @@
|
||||
</picture>
|
||||
</details>
|
||||
|
||||
<details open>
|
||||
<details>
|
||||
<summary> 管理员信息 </summary>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/840dca69-e67d-4083-88f8-8e67c3e47141">
|
||||
@ -36,7 +36,7 @@
|
||||
</picture>
|
||||
</details>
|
||||
|
||||
<details open>
|
||||
<details>
|
||||
<summary> 设置 </summary>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/8fc8c489-b9cd-4e34-ad32-4899ccc275e9">
|
||||
@ -44,7 +44,7 @@
|
||||
</picture>
|
||||
</details>
|
||||
|
||||
<details open>
|
||||
<details>
|
||||
<summary> 关于 </summary>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/dbef2d66-4ca4-4e89-8292-dbdce3566f93">
|
||||
|
298
gui/pom.xml
@ -1,298 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.octopusyan</groupId>
|
||||
<artifactId>alist-gui</artifactId>
|
||||
<version>${gui.version}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>gui</artifactId>
|
||||
<version>${gui.version}</version>
|
||||
<name>alist-gui</name>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<java.version>21</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
||||
<parent.version>${gui.version}</parent.version>
|
||||
|
||||
<exec.mainClass>cn.octopusyan.alistgui.AppLauncher</exec.mainClass>
|
||||
<cssSrcPath>${project.basedir}/src/main/resources/css</cssSrcPath>
|
||||
<cssTargetPath>${project.basedir}/target/classes/css</cssTargetPath>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- javafx -->
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-controls</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-fxml</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mkpaz.github.io/atlantafx/ -->
|
||||
<dependency>
|
||||
<groupId>io.github.mkpaz</groupId>
|
||||
<artifactId>atlantafx-base</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- slf4j -->
|
||||
<!-- https://slf4j.org/manual.html -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- common -->
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-exec -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-exec</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- hutool -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- jackson -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-yaml</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- https://kordamp.org/ikonli/ -->
|
||||
<dependency>
|
||||
<groupId>org.kordamp.ikonli</groupId>
|
||||
<artifactId>ikonli-javafx</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kordamp.ikonli</groupId>
|
||||
<artifactId>ikonli-fontawesome-pack</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gluonhq</groupId>
|
||||
<artifactId>emoji</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<excludes>
|
||||
<exclude>css/*.scss</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>21</source>
|
||||
<target>21</target>
|
||||
<compilerArgs>--enable-preview</compilerArgs>
|
||||
<encoding>UTF-8</encoding>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- https://github.com/HebiRobotics/sass-cli-maven-plugin -->
|
||||
<plugin>
|
||||
<groupId>us.hebi.sass</groupId>
|
||||
<artifactId>sass-cli-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<sassVersion>1.78.0</sassVersion>
|
||||
<args> <!-- Any argument that should be forwarded to the sass cli -->
|
||||
<arg>${cssSrcPath}/root.scss:${cssTargetPath}/root.css</arg>
|
||||
<arg>${cssSrcPath}/root-view.scss:${cssTargetPath}/root-view.css</arg>
|
||||
<arg>${cssSrcPath}/main-view.scss:${cssTargetPath}/main-view.css</arg>
|
||||
<arg>${cssSrcPath}/setup-view.scss:${cssTargetPath}/setup-view.css</arg>
|
||||
<arg>${cssSrcPath}/about-view.scss:${cssTargetPath}/about-view.css</arg>
|
||||
<arg>${cssSrcPath}/admin-panel.scss:${cssTargetPath}/admin-panel.css</arg>
|
||||
<arg>--no-source-map</arg>
|
||||
</args>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sass-exec</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<stripDebug>true</stripDebug>
|
||||
<compress>2</compress>
|
||||
<noHeaderFiles>true</noHeaderFiles>
|
||||
<noManPages>true</noManPages>
|
||||
<launcher>alistgui</launcher>
|
||||
<jlinkImageName>app</jlinkImageName>
|
||||
<jlinkZipName>app</jlinkZipName>
|
||||
<mainClass>cn.octopusyan.alistgui/${exec.mainClass}</mainClass>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<!-- Default configuration for running with: mvn clean javafx:run -->
|
||||
<id>default-cli</id>
|
||||
<configuration>
|
||||
<stripDebug>true</stripDebug>
|
||||
<compress>2</compress>
|
||||
<noHeaderFiles>true</noHeaderFiles>
|
||||
<noManPages>true</noManPages>
|
||||
<launcher>alist-gui</launcher>
|
||||
<jlinkImageName>app</jlinkImageName>
|
||||
<jlinkZipName>app</jlinkZipName>
|
||||
<mainClass>cn.octopusyan.alistgui/${exec.mainClass}</mainClass>
|
||||
<options>
|
||||
<option>--enable-preview</option>
|
||||
<!-- <option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005</option>-->
|
||||
</options>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- https://github.com/fvarrui/JavaPackager -->
|
||||
<plugin>
|
||||
<groupId>io.github.fvarrui</groupId>
|
||||
<artifactId>javapackager</artifactId>
|
||||
<configuration>
|
||||
<mainClass>${exec.mainClass}</mainClass>
|
||||
<bundleJre>true</bundleJre>
|
||||
<generateInstaller>false</generateInstaller>
|
||||
<copyDependencies>true</copyDependencies>
|
||||
<assetsDir>${project.basedir}/src/main/resources/assets</assetsDir>
|
||||
<vmArgs>
|
||||
<arg>--enable-preview</arg>
|
||||
<arg>-Xmx100m</arg>
|
||||
</vmArgs>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>windows</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>package</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<platform>windows</platform>
|
||||
<zipballName>${project.name}-windows</zipballName>
|
||||
<createZipball>true</createZipball>
|
||||
<winConfig>
|
||||
<headerType>gui</headerType>
|
||||
<generateMsi>false</generateMsi>
|
||||
</winConfig>
|
||||
<additionalResources>
|
||||
<additionalResource>${project.basedir}/src/main/resources/static/upgrade.exe
|
||||
</additionalResource>
|
||||
</additionalResources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>windows-nojre</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>package</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<zipballName>${project.name}-windows-nojre</zipballName>
|
||||
<platform>windows</platform>
|
||||
<createZipball>true</createZipball>
|
||||
<bundleJre>false</bundleJre>
|
||||
<winConfig>
|
||||
<headerType>gui</headerType>
|
||||
<generateMsi>false</generateMsi>
|
||||
</winConfig>
|
||||
<additionalResources>
|
||||
<additionalResource>${project.basedir}/src/main/resources/static/upgrade.exe
|
||||
</additionalResource>
|
||||
</additionalResources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<configuration>
|
||||
<nonFilteredFileExtensions>
|
||||
<nonFilteredFileExtension>exe</nonFilteredFileExtension>
|
||||
</nonFilteredFileExtensions>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<!--打成jar包后复制到的路径-->
|
||||
<outputDirectory>../target</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<!--项目中需要复制的文件路径-->
|
||||
<directory>${project.basedir}/target</directory>
|
||||
<includes>
|
||||
<include>*.zip</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
138
pom.xml
@ -6,9 +6,8 @@
|
||||
|
||||
<groupId>cn.octopusyan</groupId>
|
||||
<artifactId>alist-gui</artifactId>
|
||||
<version>${gui.version}</version>
|
||||
<version>1.0.2</version>
|
||||
<name>alist-gui</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<organization>
|
||||
<name>octopus_yan</name>
|
||||
@ -18,11 +17,6 @@
|
||||
<inceptionYear>2024</inceptionYear>
|
||||
<description>AList GUI</description>
|
||||
|
||||
<modules>
|
||||
<module>upgrade</module>
|
||||
<module>gui</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
@ -30,7 +24,9 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
||||
<gui.version>1.0.3</gui.version>
|
||||
<exec.mainClass>cn.octopusyan.alistgui.AppLauncher</exec.mainClass>
|
||||
<cssSrcPath>${project.basedir}/src/main/resources/css</cssSrcPath>
|
||||
<cssTargetPath>${project.basedir}/target/classes/css</cssTargetPath>
|
||||
|
||||
<junit.version>5.10.0</junit.version>
|
||||
<javafx.version>21.0.4</javafx.version>
|
||||
@ -46,10 +42,7 @@
|
||||
<gluonhq-emoji.version>1.0.1</gluonhq-emoji.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- javafx -->
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
@ -140,7 +133,6 @@
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
@ -158,13 +150,35 @@
|
||||
</pluginRepositories>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<excludes>
|
||||
<exclude>css/*.scss</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version>
|
||||
<configuration>
|
||||
<source>21</source>
|
||||
<target>21</target>
|
||||
<compilerArgs>--enable-preview</compilerArgs>
|
||||
<encoding>UTF-8</encoding>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- https://github.com/HebiRobotics/sass-cli-maven-plugin -->
|
||||
@ -172,12 +186,63 @@
|
||||
<groupId>us.hebi.sass</groupId>
|
||||
<artifactId>sass-cli-maven-plugin</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<configuration>
|
||||
<sassVersion>1.78.0</sassVersion>
|
||||
<args> <!-- Any argument that should be forwarded to the sass cli -->
|
||||
<arg>${cssSrcPath}/root.scss:${cssTargetPath}/root.css</arg>
|
||||
<arg>${cssSrcPath}/root-view.scss:${cssTargetPath}/root-view.css</arg>
|
||||
<arg>${cssSrcPath}/main-view.scss:${cssTargetPath}/main-view.css</arg>
|
||||
<arg>${cssSrcPath}/setup-view.scss:${cssTargetPath}/setup-view.css</arg>
|
||||
<arg>${cssSrcPath}/about-view.scss:${cssTargetPath}/about-view.css</arg>
|
||||
<arg>${cssSrcPath}/admin-panel.scss:${cssTargetPath}/admin-panel.css</arg>
|
||||
<arg>--no-source-map</arg>
|
||||
</args>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sass-exec</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-maven-plugin</artifactId>
|
||||
<version>0.0.8</version>
|
||||
<configuration>
|
||||
<stripDebug>true</stripDebug>
|
||||
<compress>2</compress>
|
||||
<noHeaderFiles>true</noHeaderFiles>
|
||||
<noManPages>true</noManPages>
|
||||
<launcher>alistgui</launcher>
|
||||
<jlinkImageName>app</jlinkImageName>
|
||||
<jlinkZipName>app</jlinkZipName>
|
||||
<mainClass>cn.octopusyan.alistgui/${exec.mainClass}</mainClass>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<!-- Default configuration for running with: mvn clean javafx:run -->
|
||||
<id>default-cli</id>
|
||||
<configuration>
|
||||
<stripDebug>true</stripDebug>
|
||||
<compress>2</compress>
|
||||
<noHeaderFiles>true</noHeaderFiles>
|
||||
<noManPages>true</noManPages>
|
||||
<launcher>alist-gui</launcher>
|
||||
<jlinkImageName>app</jlinkImageName>
|
||||
<jlinkZipName>app</jlinkZipName>
|
||||
<mainClass>cn.octopusyan.alistgui/${exec.mainClass}</mainClass>
|
||||
<options>
|
||||
<option>--enable-preview</option>
|
||||
<!-- <option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005</option>-->
|
||||
</options>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- https://github.com/fvarrui/JavaPackager -->
|
||||
@ -185,8 +250,53 @@
|
||||
<groupId>io.github.fvarrui</groupId>
|
||||
<artifactId>javapackager</artifactId>
|
||||
<version>1.7.7-SNAPSHOT</version>
|
||||
<configuration>
|
||||
<mainClass>${exec.mainClass}</mainClass>
|
||||
<bundleJre>true</bundleJre>
|
||||
<generateInstaller>false</generateInstaller>
|
||||
<copyDependencies>true</copyDependencies>
|
||||
<assetsDir>${project.basedir}/src/main/resources/assets</assetsDir>
|
||||
<vmArgs>
|
||||
<arg>--enable-preview</arg>
|
||||
<arg>-Xmx100m</arg>
|
||||
</vmArgs>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>windows</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>package</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<platform>windows</platform>
|
||||
<zipballName>${project.name}-windows</zipballName>
|
||||
<createZipball>true</createZipball>
|
||||
<winConfig>
|
||||
<headerType>gui</headerType>
|
||||
<generateMsi>false</generateMsi>
|
||||
</winConfig>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>windows-nojre</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>package</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<zipballName>${project.name}-windows-nojre</zipballName>
|
||||
<platform>windows</platform>
|
||||
<createZipball>true</createZipball>
|
||||
<bundleJre>false</bundleJre>
|
||||
<winConfig>
|
||||
<headerType>gui</headerType>
|
||||
<generateMsi>false</generateMsi>
|
||||
</winConfig>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
@ -1,6 +1,5 @@
|
||||
package cn.octopusyan.alistgui;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.octopusyan.alistgui.config.Constants;
|
||||
import cn.octopusyan.alistgui.config.Context;
|
||||
import cn.octopusyan.alistgui.manager.ConfigManager;
|
||||
@ -8,7 +7,6 @@ import cn.octopusyan.alistgui.manager.SystemTrayManager;
|
||||
import cn.octopusyan.alistgui.manager.http.HttpConfig;
|
||||
import cn.octopusyan.alistgui.manager.http.HttpUtil;
|
||||
import cn.octopusyan.alistgui.manager.thread.ThreadPoolManager;
|
||||
import cn.octopusyan.alistgui.model.upgrade.Gui;
|
||||
import cn.octopusyan.alistgui.util.ProcessesUtil;
|
||||
import cn.octopusyan.alistgui.view.alert.AlertUtil;
|
||||
import javafx.application.Platform;
|
||||
@ -24,8 +22,6 @@ import java.io.*;
|
||||
import java.net.*;
|
||||
import java.net.http.HttpClient;
|
||||
import java.util.Objects;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
@ -35,25 +31,11 @@ public class Application extends javafx.application.Application {
|
||||
private static Stage primaryStage;
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
public void init() {
|
||||
logger.info("application init ...");
|
||||
|
||||
long delay = 0L;
|
||||
// 更新重启检查
|
||||
File upgradeFile = new File(Constants.DATA_DIR_PATH + File.separator + new Gui().getReleaseFile());
|
||||
// logger.error("{}{}{}", Constants.DATA_DIR_PATH, File.separator, new Gui().getReleaseFile());
|
||||
if (upgradeFile.exists()) {
|
||||
logger.error("upgradeFile.exists");
|
||||
FileUtil.del(upgradeFile);
|
||||
delay = 1000;
|
||||
}
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 单例模式检查
|
||||
makeSingle();
|
||||
}
|
||||
}, delay);
|
||||
|
||||
// 初始化客户端配置
|
||||
ConfigManager.load();
|
||||
@ -103,7 +85,7 @@ public class Application extends javafx.application.Application {
|
||||
// 启动主界面
|
||||
primaryStage.getIcons().add(new Image(Objects.requireNonNull(this.getClass().getResourceAsStream("/assets/logo.png"))));
|
||||
primaryStage.initStyle(StageStyle.TRANSPARENT);
|
||||
primaryStage.setTitle(String.format("%s %s", Constants.APP_TITLE, Constants.APP_VERSION));
|
||||
primaryStage.setTitle(String.format("%s v%s", Constants.APP_TITLE, Constants.APP_VERSION));
|
||||
Scene scene = Context.initScene();
|
||||
primaryStage.setScene(scene);
|
||||
|
||||
@ -165,7 +147,6 @@ public class Application extends javafx.application.Application {
|
||||
instanceCheckLatch.countDown();
|
||||
|
||||
while (true) {
|
||||
logger.debug(STR."====\{instanceId}====");
|
||||
try (
|
||||
Socket clientSocket = serverSocket.accept();
|
||||
BufferedReader in = new BufferedReader(
|
@ -68,8 +68,7 @@ public abstract class BaseController<VM extends BaseViewModel> implements Initia
|
||||
case Labeled labeled -> labeled.textProperty().bind(Context.getLanguageBinding(i18n.key()));
|
||||
case Tab tab -> tab.textProperty().bind(Context.getLanguageBinding(i18n.key()));
|
||||
case MenuItem mi -> mi.textProperty().bind(Context.getLanguageBinding(i18n.key()));
|
||||
default -> {
|
||||
}
|
||||
default -> {}
|
||||
}
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ public class Constants {
|
||||
public static final String APP_NAME = PropertiesUtils.getInstance().getProperty("app.name");
|
||||
public static final String APP_VERSION = PropertiesUtils.getInstance().getProperty("app.version");
|
||||
|
||||
public static final String DATA_DIR_PATH = Paths.get("").toFile().getAbsolutePath();
|
||||
public static final String DATA_DIR_PATH = Paths.get(".").toFile().getAbsolutePath();
|
||||
public static final String BIN_DIR_PATH = STR."\{DATA_DIR_PATH}\{File.separator}bin";
|
||||
public static final String TMP_DIR_PATH = System.getProperty("java.io.tmpdir") + APP_NAME;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.octopusyan.alistgui.controller;
|
||||
|
||||
import cn.octopusyan.alistgui.base.BaseController;
|
||||
import cn.octopusyan.alistgui.config.I18n;
|
||||
import cn.octopusyan.alistgui.manager.ConfigManager;
|
||||
import cn.octopusyan.alistgui.viewModel.AboutViewModule;
|
||||
import javafx.scene.control.Button;
|
||||
@ -21,12 +22,16 @@ public class AboutController extends BaseController<AboutViewModule> {
|
||||
|
||||
public Label aListVersion;
|
||||
|
||||
@I18n(key = "about.alist.version")
|
||||
public Label aListVersionLabel;
|
||||
|
||||
@I18n(key = "about.app.version")
|
||||
public Label appVersionLabel;
|
||||
|
||||
@I18n(key = "about.app.update")
|
||||
public Button checkAppVersion;
|
||||
|
||||
@I18n(key = "about.alist.update")
|
||||
public Button checkAListVersion;
|
||||
|
||||
@Override
|
@ -2,6 +2,7 @@ package cn.octopusyan.alistgui.controller;
|
||||
|
||||
import cn.octopusyan.alistgui.base.BaseController;
|
||||
import cn.octopusyan.alistgui.config.Context;
|
||||
import cn.octopusyan.alistgui.config.I18n;
|
||||
import cn.octopusyan.alistgui.manager.AListManager;
|
||||
import cn.octopusyan.alistgui.manager.ConsoleLog;
|
||||
import cn.octopusyan.alistgui.util.FxmlUtil;
|
||||
@ -31,20 +32,28 @@ public class MainController extends BaseController<MainViewModel> {
|
||||
public VBox logArea;
|
||||
public ScrollPane logAreaSp;
|
||||
|
||||
@I18n(key = "main.status.label-stop")
|
||||
public Button statusLabel;
|
||||
|
||||
@I18n(key = "main.control.start")
|
||||
public Button startButton;
|
||||
|
||||
@I18n(key = "main.control.password")
|
||||
public Button passwordButton;
|
||||
|
||||
@I18n(key = "main.control.restart")
|
||||
public Button restartButton;
|
||||
|
||||
@I18n(key = "main.control.more")
|
||||
public MenuButton moreButton;
|
||||
|
||||
@I18n(key = "main.more.browser")
|
||||
public MenuItem browserButton;
|
||||
|
||||
@I18n(key = "main.more.open-config")
|
||||
public MenuItem configButton;
|
||||
|
||||
@I18n(key = "main.more.open-log")
|
||||
public MenuItem logButton;
|
||||
|
||||
private PasswordController controller;
|
@ -4,6 +4,7 @@ import atlantafx.base.controls.Popover;
|
||||
import cn.hutool.core.swing.clipboard.ClipboardUtil;
|
||||
import cn.octopusyan.alistgui.base.BaseController;
|
||||
import cn.octopusyan.alistgui.config.Context;
|
||||
import cn.octopusyan.alistgui.config.I18n;
|
||||
import cn.octopusyan.alistgui.manager.AListManager;
|
||||
import cn.octopusyan.alistgui.viewModel.AdminPanelViewModel;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
@ -26,11 +27,14 @@ import org.apache.commons.lang3.StringUtils;
|
||||
public class PasswordController extends BaseController<AdminPanelViewModel> {
|
||||
public AnchorPane adminPanel;
|
||||
|
||||
@I18n(key = "admin.pwd.toptip")
|
||||
public Label toptip;
|
||||
@I18n(key = "admin.pwd.user-field")
|
||||
public Label usernameLabel;
|
||||
public TextField usernameField;
|
||||
@FXML
|
||||
public Button copyUsername;
|
||||
@I18n(key = "admin.pwd.pwd-field")
|
||||
public Label passwordLabel;
|
||||
public PasswordField passwordField;
|
||||
public Button refreshPassword;
|
@ -3,6 +3,7 @@ package cn.octopusyan.alistgui.controller;
|
||||
import atlantafx.base.controls.ModalPane;
|
||||
import cn.octopusyan.alistgui.base.BaseController;
|
||||
import cn.octopusyan.alistgui.config.Context;
|
||||
import cn.octopusyan.alistgui.config.I18n;
|
||||
import cn.octopusyan.alistgui.manager.ConfigManager;
|
||||
import cn.octopusyan.alistgui.manager.SystemTrayManager;
|
||||
import cn.octopusyan.alistgui.util.ViewUtil;
|
||||
@ -40,13 +41,19 @@ public class RootController extends BaseController<RootViewModel> {
|
||||
// 界面
|
||||
public TabPane tabPane;
|
||||
|
||||
@I18n(key = "root.tab.main")
|
||||
public Tab mainTab;
|
||||
@I18n(key = "root.tab.setup")
|
||||
public Tab setupTab;
|
||||
@I18n(key = "root.tab.about")
|
||||
public Tab aboutTab;
|
||||
|
||||
// footer
|
||||
@I18n(key = "root.foot.doc")
|
||||
public Button document;
|
||||
@I18n(key = "root.foot.github")
|
||||
public Button github;
|
||||
@I18n(key = "root.foot.sponsor")
|
||||
public Button sponsor;
|
||||
|
||||
private final ModalPane modalPane = new ModalPane();
|
@ -3,6 +3,7 @@ package cn.octopusyan.alistgui.controller;
|
||||
import atlantafx.base.theme.Theme;
|
||||
import cn.octopusyan.alistgui.base.BaseController;
|
||||
import cn.octopusyan.alistgui.config.Context;
|
||||
import cn.octopusyan.alistgui.config.I18n;
|
||||
import cn.octopusyan.alistgui.enums.ProxySetup;
|
||||
import cn.octopusyan.alistgui.manager.ConfigManager;
|
||||
import cn.octopusyan.alistgui.view.ProxySetupCell;
|
||||
@ -30,20 +31,29 @@ public class SetupController extends BaseController<SetupViewModel> implements I
|
||||
|
||||
@FXML
|
||||
public VBox setupView;
|
||||
@I18n(key = "setup.auto-start.label")
|
||||
public CheckBox autoStartCheckBox;
|
||||
@I18n(key = "setup.silent-startup.label")
|
||||
public CheckBox silentStartupCheckBox;
|
||||
@I18n(key = "setup.close-to-tray.label")
|
||||
public CheckBox closeToTrayCheckBox;
|
||||
@I18n(key = "setup.theme")
|
||||
public Label themeLabel;
|
||||
public ComboBox<Theme> themeComboBox;
|
||||
@I18n(key = "setup.language")
|
||||
public Label languageLabel;
|
||||
public ComboBox<Locale> languageComboBox;
|
||||
@I18n(key = "setup.proxy")
|
||||
public Label proxySetupLabel;
|
||||
public ComboBox<ProxySetup> proxySetupComboBox;
|
||||
public Pane proxySetupPane;
|
||||
@I18n(key = "setup.proxy.test")
|
||||
public Button proxyCheck;
|
||||
public TextField proxyHost;
|
||||
public TextField proxyPort;
|
||||
@I18n(key = "setup.proxy.host")
|
||||
public Label hostLabel;
|
||||
@I18n(key = "setup.proxy.port")
|
||||
public Label portLabel;
|
||||
|
||||
@Override
|
@ -143,21 +143,24 @@ public class AListManager {
|
||||
ConsoleLog.info(getText("alist.status.stop"));
|
||||
if (!running.get()) {
|
||||
ConsoleLog.warning(getText("alist.status.stop.stopped"));
|
||||
return;
|
||||
}
|
||||
util.destroy();
|
||||
}
|
||||
|
||||
static ChangeListener<Boolean> restartListener = (_, _, run) -> {
|
||||
if (run) return;
|
||||
running.removeListener(AListManager.restartListener);
|
||||
start();
|
||||
};
|
||||
static ChangeListener<Boolean> restartListener;
|
||||
|
||||
public static void restart() {
|
||||
if (!running.get()) {
|
||||
start();
|
||||
} else {
|
||||
stop();
|
||||
|
||||
restartListener = (_, _, run) -> {
|
||||
if (run) return;
|
||||
running.removeListener(restartListener);
|
||||
start();
|
||||
};
|
||||
running.addListener(restartListener);
|
||||
}
|
||||
}
|
||||
@ -191,7 +194,7 @@ public class AListManager {
|
||||
//============================={ private }====================================
|
||||
|
||||
/**
|
||||
* 点击开始时检查 aList 执行文件
|
||||
* TODO 点击开始时检查 aList 执行文件
|
||||
*/
|
||||
private static boolean checkAList() {
|
||||
if (new File(Constants.ALIST_FILE).exists()) return true;
|
||||
@ -213,11 +216,6 @@ public class AListManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始下载AList
|
||||
*
|
||||
* @param version 下载版本号
|
||||
*/
|
||||
private static void showDownload(String version) {
|
||||
String content = STR."""
|
||||
\{getText("msg.alist.download.notfile")}
|
@ -19,10 +19,9 @@ import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -34,7 +33,7 @@ public class ConsoleLog {
|
||||
public static final String format = "yyyy/MM/dd hh:mm:ss";
|
||||
private volatile static ConsoleLog log;
|
||||
private final VBox textArea;
|
||||
private final static String CONSOLE_COLOR_PREFIX = "\033[";
|
||||
private final static String CONSOLE_COLOR_PREFIX = "^\033[";
|
||||
private final static String CONSOLE_MSG_REX = "^\033\\[(\\d+)m(.*)\033\\[0m(.*)$";
|
||||
private final static String URL_IP_REX = "^((ht|f)tps?:\\/\\/)?[\\w-+&@#/%?=~_|!:,.;]*[\\w-+&@#/%=~_|]+(:\\d{1,5})?\\/?$";
|
||||
|
||||
@ -89,6 +88,16 @@ public class ConsoleLog {
|
||||
if (StringUtils.isEmpty(message) || !isInit()) return;
|
||||
message = message.strip();
|
||||
message = StrUtil.format(message, param);
|
||||
|
||||
// 多颜色消息处理
|
||||
if (StringUtils.countMatches(message, CONSOLE_COLOR_PREFIX) > 1) {
|
||||
String[] split = message.replace(CONSOLE_MSG_REX, "\n%s".formatted(CONSOLE_COLOR_PREFIX)).split("\n");
|
||||
List<String> msgs = Arrays.stream(split).toList();
|
||||
for (String msg : msgs) {
|
||||
msg(msg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
message = setPwdText(message);
|
||||
message = resetConsoleColor(message);
|
||||
|
||||
@ -178,35 +187,17 @@ public class ConsoleLog {
|
||||
/**
|
||||
* 控制台输出颜色
|
||||
*
|
||||
* @param msg 输出消息
|
||||
* @param msg alist 输出消息
|
||||
* @return bbcode 颜色文本
|
||||
*/
|
||||
private static String resetConsoleColor(String msg) {
|
||||
if (!msg.contains(CONSOLE_COLOR_PREFIX) || !Pattern.matches(CONSOLE_MSG_REX, msg)) return msg;
|
||||
if (!msg.contains("\033[")) return msg;
|
||||
|
||||
// 多颜色处理
|
||||
String[] split = Pattern.compile("\\033\\[(\\d;)?(\\d+)m")
|
||||
.matcher(msg)
|
||||
.replaceAll(matchResult -> "\n" + matchResult.group())
|
||||
.replaceFirst("\n", "")
|
||||
.split("\n");
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Pattern pattern = Pattern.compile("\\033\\[(\\d;)?(\\d+)m(.*)");
|
||||
Matcher matcher;
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
matcher = pattern.matcher(split[i]);
|
||||
if(!matcher.matches()) continue;
|
||||
|
||||
if (i % 2 == 0) {
|
||||
String color = StringUtils.lowerCase(Color.valueOf(Integer.parseInt(matcher.group(2))).getColor());
|
||||
sb.append(color(color, matcher.group(3)));
|
||||
} else {
|
||||
sb.append(matcher.group(3));
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
String colorCode = ReUtil.get(CONSOLE_MSG_REX, msg, 1);
|
||||
String color = StringUtils.lowerCase(Color.valueOf(Integer.parseInt(colorCode)).getColor());
|
||||
String colorMsg = ReUtil.get(CONSOLE_MSG_REX, msg, 2);
|
||||
msg = ReUtil.get(CONSOLE_MSG_REX, msg, 3);
|
||||
return color(color, colorMsg) + msg;
|
||||
}
|
||||
|
||||
/**
|
@ -62,10 +62,6 @@ public class DownloadUtil {
|
||||
}
|
||||
|
||||
public static void unzip(UpgradeApp app) {
|
||||
unzip(app, true);
|
||||
}
|
||||
|
||||
public static void unzip(UpgradeApp app, boolean del) {
|
||||
String parentPath = app instanceof AList ? Constants.BIN_DIR_PATH : Constants.DATA_DIR_PATH;
|
||||
|
||||
File file = new File(parentPath + File.separator + app.getReleaseFile());
|
||||
@ -97,6 +93,6 @@ public class DownloadUtil {
|
||||
});
|
||||
|
||||
// 解压完成后删除
|
||||
if (del) FileUtil.del(file);
|
||||
FileUtil.del(file);
|
||||
}
|
||||
}
|
@ -53,7 +53,7 @@ public class ProcessesUtil {
|
||||
commandLine = CommandLine.parse(command);
|
||||
int execute = 0;
|
||||
try {
|
||||
executor.execute(commandLine, new DefaultExecuteResultHandler());
|
||||
execute = executor.execute(commandLine);
|
||||
} catch (Exception e) {
|
||||
log.error("exec", e);
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
package cn.octopusyan.alistgui.util;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 注册表编辑
|
||||
*
|
||||
@ -47,7 +45,6 @@ public class Registry {
|
||||
UNLOAD,
|
||||
}
|
||||
|
||||
@Getter
|
||||
public enum Root {
|
||||
HKCR("HKEY_CLASSES_ROOT"),
|
||||
HKCU("HKEY_CURRENT_USER"),
|
||||
@ -62,6 +59,9 @@ public class Registry {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
public enum DataType {
|
@ -1,5 +1,6 @@
|
||||
package cn.octopusyan.alistgui.viewModel;
|
||||
|
||||
import cn.octopusyan.alistgui.Application;
|
||||
import cn.octopusyan.alistgui.base.BaseViewModel;
|
||||
import cn.octopusyan.alistgui.config.Constants;
|
||||
import cn.octopusyan.alistgui.config.Context;
|
||||
@ -17,7 +18,6 @@ import cn.octopusyan.alistgui.view.alert.AlertUtil;
|
||||
import cn.octopusyan.alistgui.view.alert.builder.AlertBuilder;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.*;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
@ -142,25 +142,24 @@ public class AboutViewModule extends BaseViewModel {
|
||||
if (upgrade)
|
||||
DownloadUtil.startDownload(app, newVersion, () -> {
|
||||
|
||||
// 下载完成后,解压并删除文件
|
||||
DownloadUtil.unzip(app);
|
||||
|
||||
// 解压后
|
||||
Platform.runLater(() -> {
|
||||
switch (app) {
|
||||
case AList _ -> {
|
||||
if(AListManager.isRunning()) {
|
||||
AListManager.stop();
|
||||
AListManager.runningProperty().addListener(updateListener);
|
||||
} else {
|
||||
// 下载完成后,解压并删除文件
|
||||
DownloadUtil.unzip(app);
|
||||
}
|
||||
// 设置应用版本
|
||||
aListVersion.setValue(aListNewVersion.getValue());
|
||||
AListManager.restart();
|
||||
}
|
||||
case Gui _ -> {
|
||||
log.info(STR."guiNewVersion => \{guiNewVersion.get()}");
|
||||
// 启动升级程序
|
||||
ProcessesUtil.init(Constants.DATA_DIR_PATH).exec("upgrade.exe");
|
||||
Platform.exit();
|
||||
// 重启
|
||||
Platform.setImplicitExit(true);
|
||||
Application.getPrimaryStage().close();
|
||||
|
||||
ProcessesUtil.init(Constants.DATA_DIR_PATH).exec(STR."\{Constants.APP_NAME}.exe");
|
||||
}
|
||||
default -> throw new IllegalStateException(STR."Unexpected value: \{app}");
|
||||
}
|
||||
@ -169,12 +168,4 @@ public class AboutViewModule extends BaseViewModel {
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
static final ChangeListener<Boolean> updateListener = (_, _, run) -> {
|
||||
if (!run) {
|
||||
// 下载完成后,解压并删除文件
|
||||
DownloadUtil.unzip(ConfigManager.aList());
|
||||
}
|
||||
AListManager.runningProperty().removeListener(AboutViewModule.updateListener);
|
||||
};
|
||||
}
|
@ -65,14 +65,8 @@ public class SetupViewModel extends BaseViewModel {
|
||||
proxySetup.addListener((_, _, newValue) -> ConfigManager.proxySetup(newValue));
|
||||
proxyTestUrl.addListener((_, _, newValue) -> ConfigManager.proxyTestUrl(newValue));
|
||||
proxyHost.addListener((_, _, newValue) -> ConfigManager.proxyHost(newValue));
|
||||
proxyHost.addListener((_, _, newValue) -> {
|
||||
ConfigManager.proxyHost(newValue);
|
||||
setProxy();
|
||||
});
|
||||
proxyPort.addListener((_, _, newValue) -> {
|
||||
ConfigManager.proxyPort(newValue);
|
||||
setProxy();
|
||||
});
|
||||
proxyPort.addListener((_, _, newValue) -> ConfigManager.proxyPort(newValue));
|
||||
language.addListener((_, _, newValue) -> Context.setLanguage(newValue));
|
||||
}
|
||||
|
||||
public ObjectProperty<Theme> themeProperty() {
|
||||
@ -129,14 +123,6 @@ 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) {
|
@ -24,5 +24,4 @@ module cn.octopusyan.alistgui {
|
||||
opens cn.octopusyan.alistgui.controller to javafx.fxml;
|
||||
opens cn.octopusyan.alistgui.base to com.fasterxml.jackson.databind;
|
||||
opens cn.octopusyan.alistgui.model.upgrade to com.fasterxml.jackson.databind;
|
||||
exports cn.octopusyan.alistgui.model.upgrade;
|
||||
}
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 960 B After Width: | Height: | Size: 960 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
171
upgrade/pom.xml
@ -1,171 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.octopusyan</groupId>
|
||||
<artifactId>alist-gui</artifactId>
|
||||
<version>${gui.version}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>upgrade</artifactId>
|
||||
<version>${gui.version}</version>
|
||||
<name>upgrade</name>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<java.version>21</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
||||
<exec.mainClass>cn.octopusyan.upgrade.AppLauncher</exec.mainClass>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- javafx -->
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-controls</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-fxml</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mkpaz.github.io/atlantafx/ -->
|
||||
<dependency>
|
||||
<groupId>io.github.mkpaz</groupId>
|
||||
<artifactId>atlantafx-base</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>21</source>
|
||||
<target>21</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<stripDebug>true</stripDebug>
|
||||
<compress>2</compress>
|
||||
<noHeaderFiles>true</noHeaderFiles>
|
||||
<noManPages>true</noManPages>
|
||||
<launcher>upgrade</launcher>
|
||||
<jlinkImageName>app</jlinkImageName>
|
||||
<jlinkZipName>app</jlinkZipName>
|
||||
<mainClass>cn.octopusyan.upgrade/${exec.mainClass}</mainClass>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<!-- Default configuration for running with: mvn clean javafx:run -->
|
||||
<id>default-cli</id>
|
||||
<configuration>
|
||||
<stripDebug>true</stripDebug>
|
||||
<compress>2</compress>
|
||||
<noHeaderFiles>true</noHeaderFiles>
|
||||
<noManPages>true</noManPages>
|
||||
<launcher>upgrade</launcher>
|
||||
<jlinkImageName>app</jlinkImageName>
|
||||
<jlinkZipName>app</jlinkZipName>
|
||||
<mainClass>cn.octopusyan.upgrade/${exec.mainClass}</mainClass>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- https://github.com/fvarrui/JavaPackager -->
|
||||
<plugin>
|
||||
<groupId>io.github.fvarrui</groupId>
|
||||
<artifactId>javapackager</artifactId>
|
||||
<configuration>
|
||||
<mainClass>${exec.mainClass}</mainClass>
|
||||
<bundleJre>true</bundleJre>
|
||||
<generateInstaller>false</generateInstaller>
|
||||
<copyDependencies>true</copyDependencies>
|
||||
<vmArgs>
|
||||
<arg>-Xmx100m</arg>
|
||||
</vmArgs>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>windows</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>package</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<platform>windows</platform>
|
||||
<createZipball>false</createZipball>
|
||||
<winConfig>
|
||||
<headerType>gui</headerType>
|
||||
<generateMsi>false</generateMsi>
|
||||
</winConfig>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<!--打成jar包后复制到的路径-->
|
||||
<outputDirectory>../gui/src/main/resources/static</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<!--项目中需要复制的文件路径-->
|
||||
<directory>./target/upgrade</directory>
|
||||
<includes>
|
||||
<include>upgrade.exe</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<!--可配置多个提取复制路径只需要 “<id>”名字不一样即可-->
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -1,13 +0,0 @@
|
||||
package cn.octopusyan.upgrade;
|
||||
|
||||
/**
|
||||
* 启动类
|
||||
*
|
||||
* @author octopus_yan@foxmail.com
|
||||
*/
|
||||
public class AppLauncher {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Application.launch(Application.class, args);
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package cn.octopusyan.upgrade;
|
||||
|
||||
import atlantafx.base.theme.PrimerLight;
|
||||
import cn.octopusyan.upgrade.util.FxmlUtil;
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class Application extends javafx.application.Application {
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws IOException {
|
||||
|
||||
// 主题样式
|
||||
Application.setUserAgentStylesheet(new PrimerLight().getUserAgentStylesheet());
|
||||
|
||||
// 启动主界面
|
||||
Pane root = FxmlUtil.init("/fxml/hello-view.fxml").load();
|
||||
Scene scene = new Scene(root, 420, 240);
|
||||
primaryStage.setTitle(ResourceBundle.getBundle("language/language").getString("title"));
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
// 关闭主界面
|
||||
Platform.exit();
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
package cn.octopusyan.upgrade.alert;
|
||||
|
||||
import cn.octopusyan.upgrade.alert.builder.*;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.Window;
|
||||
|
||||
/**
|
||||
* 弹窗工具
|
||||
*
|
||||
* @author octopus_yan@foxmail.com
|
||||
*/
|
||||
public class AlertUtil {
|
||||
private static Window mOwner;
|
||||
|
||||
public static void initOwner(Stage stage) {
|
||||
AlertUtil.mOwner = stage;
|
||||
}
|
||||
|
||||
public static AlertBuilder info(String content) {
|
||||
return info().content(content).header(null);
|
||||
}
|
||||
|
||||
public static AlertBuilder info() {
|
||||
return alert(Alert.AlertType.INFORMATION);
|
||||
}
|
||||
|
||||
public static AlertBuilder error(String message) {
|
||||
return alert(Alert.AlertType.ERROR).header(null).content(message);
|
||||
}
|
||||
|
||||
public static AlertBuilder warning() {
|
||||
return alert(Alert.AlertType.WARNING);
|
||||
}
|
||||
|
||||
public static AlertBuilder exception(Exception ex) {
|
||||
return alert(Alert.AlertType.ERROR).exception(ex);
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认对话框
|
||||
*/
|
||||
public static AlertBuilder confirm() {
|
||||
return alert(Alert.AlertType.CONFIRMATION);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义确认对话框 <p>
|
||||
*
|
||||
* @param buttons <code>"Cancel"</code> OR <code>"取消"</code> 为取消按钮
|
||||
*/
|
||||
public static AlertBuilder confirm(String... buttons) {
|
||||
return confirm().buttons(buttons);
|
||||
}
|
||||
|
||||
public static AlertBuilder confirm(ButtonType... buttons) {
|
||||
return confirm().buttons(buttons);
|
||||
}
|
||||
|
||||
public static AlertBuilder alert(Alert.AlertType type) {
|
||||
return new AlertBuilder(mOwner, type);
|
||||
}
|
||||
|
||||
public interface OnChoseListener {
|
||||
void confirm();
|
||||
|
||||
default void cancelOrClose(ButtonType buttonType) {
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnClickListener {
|
||||
void onClicked(String result);
|
||||
}
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
package cn.octopusyan.upgrade.alert.builder;
|
||||
|
||||
import cn.octopusyan.upgrade.alert.AlertUtil;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Priority;
|
||||
import javafx.stage.Window;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author octopus_yan
|
||||
*/
|
||||
public class AlertBuilder extends BaseBuilder<AlertBuilder, Alert> {
|
||||
|
||||
public AlertBuilder(Window owner, Alert.AlertType alertType) {
|
||||
super(new Alert(alertType), owner);
|
||||
}
|
||||
|
||||
public AlertBuilder buttons(String... buttons) {
|
||||
dialog.getButtonTypes().addAll(getButtonList(buttons));
|
||||
return this;
|
||||
}
|
||||
|
||||
public AlertBuilder buttons(ButtonType... buttons) {
|
||||
dialog.getButtonTypes().addAll(buttons);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AlertBuilder exception(Exception ex) {
|
||||
dialog.setTitle("Exception Dialog");
|
||||
dialog.setHeaderText(ex.getClass().getSimpleName());
|
||||
dialog.setContentText(ex.getMessage());
|
||||
|
||||
// 创建可扩展的异常。
|
||||
var sw = new StringWriter();
|
||||
var pw = new PrintWriter(sw);
|
||||
ex.printStackTrace(pw);
|
||||
var exceptionText = sw.toString();
|
||||
|
||||
var label = new Label("The exception stacktrace was :");
|
||||
|
||||
var textArea = new TextArea(exceptionText);
|
||||
textArea.setEditable(false);
|
||||
textArea.setWrapText(true);
|
||||
|
||||
textArea.setMaxWidth(Double.MAX_VALUE);
|
||||
textArea.setMaxHeight(Double.MAX_VALUE);
|
||||
GridPane.setVgrow(textArea, Priority.ALWAYS);
|
||||
GridPane.setHgrow(textArea, Priority.ALWAYS);
|
||||
|
||||
var expContent = new GridPane();
|
||||
expContent.setMaxWidth(Double.MAX_VALUE);
|
||||
expContent.add(label, 0, 0);
|
||||
expContent.add(textArea, 0, 1);
|
||||
|
||||
// 将可扩展异常设置到对话框窗格中。
|
||||
dialog.getDialogPane().setExpandableContent(expContent);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取按钮列表
|
||||
*
|
||||
* @param buttons "Cancel" / "取消" 为取消按钮
|
||||
*/
|
||||
private List<ButtonType> getButtonList(String[] buttons) {
|
||||
if (ArrayUtils.isEmpty(buttons)) return Collections.emptyList();
|
||||
|
||||
return Arrays.stream(buttons).map((type) -> {
|
||||
ButtonBar.ButtonData buttonData = ButtonBar.ButtonData.OTHER;
|
||||
if ("cancel".equals(StringUtils.lowerCase(type)) || "取消".equals(type)) {
|
||||
return ButtonType.CANCEL;
|
||||
}
|
||||
return new ButtonType(type, buttonData);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* AlertUtil.confirm
|
||||
*/
|
||||
public void show(AlertUtil.OnClickListener listener) {
|
||||
Optional<ButtonType> result = dialog.showAndWait();
|
||||
result.ifPresent(r -> listener.onClicked(r.getText()));
|
||||
}
|
||||
|
||||
/**
|
||||
* AlertUtil.confirm
|
||||
*/
|
||||
public void show(AlertUtil.OnChoseListener listener) {
|
||||
Optional<ButtonType> result = dialog.showAndWait();
|
||||
result.ifPresent(r -> {
|
||||
if (r == ButtonType.OK) {
|
||||
listener.confirm();
|
||||
} else {
|
||||
listener.cancelOrClose(r);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package cn.octopusyan.upgrade.alert.builder;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.control.Dialog;
|
||||
import javafx.stage.Window;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author octopus_yan
|
||||
*/
|
||||
@Getter
|
||||
public abstract class BaseBuilder<T extends BaseBuilder<T, ?>, D extends Dialog<?>> {
|
||||
protected D dialog;
|
||||
|
||||
public BaseBuilder(D dialog, Window mOwner) {
|
||||
this.dialog = dialog;
|
||||
if (mOwner != null)
|
||||
this.dialog.initOwner(mOwner);
|
||||
}
|
||||
|
||||
public T title(String title) {
|
||||
dialog.setTitle(title);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T header(String header) {
|
||||
dialog.setHeaderText(header);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T content(String content) {
|
||||
dialog.setContentText(content);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public void show() {
|
||||
Platform.runLater(() -> dialog.showAndWait());
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (dialog.isShowing())
|
||||
dialog.close();
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package cn.octopusyan.upgrade.util;
|
||||
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.JavaFXBuilderFactory;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class FxmlUtil {
|
||||
public static FXMLLoader init(String path) {
|
||||
return new FXMLLoader(
|
||||
FxmlUtil.class.getResource(path),
|
||||
ResourceBundle.getBundle("language/language"),
|
||||
new JavaFXBuilderFactory(),
|
||||
null,
|
||||
StandardCharsets.UTF_8
|
||||
);
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
package cn.octopusyan.upgrade.view;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import cn.octopusyan.upgrade.alert.AlertUtil;
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXML;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
public class HelloController {
|
||||
public static final String APP_NAME = "alist-gui";
|
||||
public static final String PARENT_PATH = Paths.get("").toFile().getAbsolutePath();
|
||||
|
||||
@FXML
|
||||
public void onUpdate() {
|
||||
// 更新检查
|
||||
File file = new File(PARENT_PATH + File.separator + APP_NAME + "-windows-nojre.zip");
|
||||
if (!file.exists()) {
|
||||
AlertUtil.error("The upgrade file does not exist!").show();
|
||||
return;
|
||||
}
|
||||
|
||||
// 解压
|
||||
unzip();
|
||||
// 启动GUI
|
||||
startGui();
|
||||
// 退出
|
||||
onExit();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void onExit() {
|
||||
Platform.exit();
|
||||
}
|
||||
|
||||
private void startGui() {
|
||||
Runtime runtime = Runtime.getRuntime(); //获取Runtime实例
|
||||
//执行命令
|
||||
String[] command = {APP_NAME + ".exe"};
|
||||
try {
|
||||
Process process = runtime.exec(command);
|
||||
} catch (IOException ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void unzip() {
|
||||
|
||||
|
||||
File file = new File(PARENT_PATH + File.separator + APP_NAME + "-windows-nojre.zip");
|
||||
ZipFile zipFile = ZipUtil.toZipFile(file, CharsetUtil.defaultCharset());
|
||||
ZipUtil.read(zipFile, zipEntry -> {
|
||||
String path = zipEntry.getName();
|
||||
if (FileUtil.isWindows()) {
|
||||
// Win系统下
|
||||
path = StrUtil.replace(path, "*", "_");
|
||||
}
|
||||
|
||||
// 打包后文件都在alist-gui文件夹下,解压时去掉
|
||||
path = path.replaceFirst(APP_NAME, "");
|
||||
|
||||
final File outItemFile = FileUtil.file(PARENT_PATH, path);
|
||||
if (zipEntry.isDirectory()) {
|
||||
// 目录
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
outItemFile.mkdirs();
|
||||
} else {
|
||||
InputStream in = ZipUtil.getStream(zipFile, zipEntry);
|
||||
// 文件
|
||||
FileUtil.writeFromStream(in, outItemFile, false);
|
||||
}
|
||||
});
|
||||
|
||||
// 解压完成后删除
|
||||
FileUtil.del(file);
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
module cn.octopusyan.upgrade {
|
||||
requires javafx.controls;
|
||||
requires javafx.fxml;
|
||||
requires atlantafx.base;
|
||||
requires cn.hutool.core;
|
||||
requires static lombok;
|
||||
requires org.apache.commons.lang3;
|
||||
|
||||
|
||||
opens cn.octopusyan.upgrade to javafx.fxml;
|
||||
exports cn.octopusyan.upgrade;
|
||||
exports cn.octopusyan.upgrade.util;
|
||||
opens cn.octopusyan.upgrade.util to javafx.fxml;
|
||||
exports cn.octopusyan.upgrade.view;
|
||||
opens cn.octopusyan.upgrade.view to javafx.fxml;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<HBox alignment="CENTER" spacing="20.0" xmlns:fx="http://javafx.com/fxml/1"
|
||||
xmlns="http://javafx.com/javafx/11.0.14-internal"
|
||||
fx:controller="cn.octopusyan.upgrade.view.HelloController">
|
||||
<padding>
|
||||
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/>
|
||||
</padding>
|
||||
<Button onAction="#onUpdate" styleClass="large" text="%update"/>
|
||||
<Button onAction="#onExit" styleClass="large" text="%exit"/>
|
||||
</HBox>
|
@ -1,7 +0,0 @@
|
||||
exit=\u9000\u51FA
|
||||
title=\u66F4\u65B0
|
||||
update=\u66F4\u65B0
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +0,0 @@
|
||||
exit=Exit
|
||||
title=Upgrade App
|
||||
update=Upgrade
|
||||
|
||||
|
||||
|
@ -1,6 +0,0 @@
|
||||
exit=\u9000\u51FA
|
||||
title=\u66F4\u65B0
|
||||
update=\u66F4\u65B0
|
||||
|
||||
|
||||
|