diff --git a/.gitignore b/.gitignore index a2a9479..2523083 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ target/ !**/src/test/**/target/ /bin/ gui.yaml +upgrade.exe ### IntelliJ IDEA ### .idea/ diff --git a/gui/pom.xml b/gui/pom.xml new file mode 100644 index 0000000..fbb3bd4 --- /dev/null +++ b/gui/pom.xml @@ -0,0 +1,315 @@ + + + 4.0.0 + + + cn.octopusyan + alist-gui + 1.0.1 + + + gui + ${parent.version} + alist-gui + + + 21 + 21 + 21 + UTF-8 + UTF-8 + + cn.octopusyan.alistgui.AppLauncher + ${project.basedir}/src/main/resources/css + ${project.basedir}/target/classes/css + + + + + + + org.openjfx + javafx-controls + + + org.openjfx + javafx-fxml + + + + + io.github.mkpaz + atlantafx-base + + + + + + org.slf4j + slf4j-api + + + ch.qos.logback + logback-classic + + + ch.qos.logback + logback-core + + + + + + org.apache.commons + commons-lang3 + + + + org.apache.commons + commons-exec + + + + + cn.hutool + hutool-core + + + + + org.projectlombok + lombok + + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + + + org.kordamp.ikonli + ikonli-javafx + + + org.kordamp.ikonli + ikonli-fontawesome-pack + + + com.gluonhq + emoji + + + + + + + nexus + nexus-snapshot-repository + https://oss.sonatype.org/content/repositories/snapshots + + true + always + + + false + + + + + + + + src/main/resources + true + + css/*.scss + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + 21 + 21 + --enable-preview + UTF-8 + + + org.projectlombok + lombok + ${lombok.version} + + + + + + + + us.hebi.sass + sass-cli-maven-plugin + 1.0.3 + + 1.78.0 + + ${cssSrcPath}/root.scss:${cssTargetPath}/root.css + ${cssSrcPath}/root-view.scss:${cssTargetPath}/root-view.css + ${cssSrcPath}/main-view.scss:${cssTargetPath}/main-view.css + ${cssSrcPath}/setup-view.scss:${cssTargetPath}/setup-view.css + ${cssSrcPath}/about-view.scss:${cssTargetPath}/about-view.css + ${cssSrcPath}/admin-panel.scss:${cssTargetPath}/admin-panel.css + --no-source-map + + + + + sass-exec + generate-resources + + run + + + + + + + org.openjfx + javafx-maven-plugin + 0.0.8 + + true + 2 + true + true + alistgui + app + app + cn.octopusyan.alistgui/${exec.mainClass} + + + + + default-cli + + true + 2 + true + true + alist-gui + app + app + cn.octopusyan.alistgui/${exec.mainClass} + + + + + + + + + + + + io.github.fvarrui + javapackager + 1.7.7-SNAPSHOT + + ${exec.mainClass} + true + false + true + ${project.basedir}/src/main/resources/assets + + --enable-preview + -Xmx100m + + + + + windows + package + + package + + + windows + ${project.name}-windows + true + + gui + false + + + ${project.basedir}/src/main/resources/static/upgrade.exe + + + + + + windows-nojre + package + + package + + + ${project.name}-windows-nojre + windows + true + false + + gui + false + + + ${project.basedir}/src/main/resources/static/upgrade.exe + + + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.3.1 + + + exe + + + + + copy-resources + package + + copy-resources + + + UTF-8 + + ../target + + + + ${project.basedir}/target + + *.zip + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/cn/octopusyan/alistgui/AppLauncher.java b/gui/src/main/java/cn/octopusyan/alistgui/AppLauncher.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/AppLauncher.java rename to gui/src/main/java/cn/octopusyan/alistgui/AppLauncher.java diff --git a/src/main/java/cn/octopusyan/alistgui/Application.java b/gui/src/main/java/cn/octopusyan/alistgui/Application.java similarity index 88% rename from src/main/java/cn/octopusyan/alistgui/Application.java rename to gui/src/main/java/cn/octopusyan/alistgui/Application.java index 79c106f..60e18a6 100644 --- a/src/main/java/cn/octopusyan/alistgui/Application.java +++ b/gui/src/main/java/cn/octopusyan/alistgui/Application.java @@ -1,5 +1,6 @@ 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; @@ -7,6 +8,7 @@ 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; @@ -22,6 +24,8 @@ 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; @@ -31,11 +35,25 @@ public class Application extends javafx.application.Application { private static Stage primaryStage; @Override - public void init() { + public void init() throws Exception { logger.info("application init ..."); - // 单例模式检查 - makeSingle(); + 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(); @@ -85,7 +103,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 v%s", Constants.APP_TITLE, Constants.APP_VERSION)); + primaryStage.setTitle(String.format("%s %s", Constants.APP_TITLE, Constants.APP_VERSION)); Scene scene = Context.initScene(); primaryStage.setScene(scene); @@ -147,6 +165,7 @@ public class Application extends javafx.application.Application { instanceCheckLatch.countDown(); while (true) { + logger.error(STR."====\{instanceId}===="); try ( Socket clientSocket = serverSocket.accept(); BufferedReader in = new BufferedReader( diff --git a/src/main/java/cn/octopusyan/alistgui/base/BaseBuilder.java b/gui/src/main/java/cn/octopusyan/alistgui/base/BaseBuilder.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/base/BaseBuilder.java rename to gui/src/main/java/cn/octopusyan/alistgui/base/BaseBuilder.java diff --git a/src/main/java/cn/octopusyan/alistgui/base/BaseController.java b/gui/src/main/java/cn/octopusyan/alistgui/base/BaseController.java similarity index 98% rename from src/main/java/cn/octopusyan/alistgui/base/BaseController.java rename to gui/src/main/java/cn/octopusyan/alistgui/base/BaseController.java index 87ec59d..585c6ee 100644 --- a/src/main/java/cn/octopusyan/alistgui/base/BaseController.java +++ b/gui/src/main/java/cn/octopusyan/alistgui/base/BaseController.java @@ -68,7 +68,8 @@ public abstract class BaseController 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 -> { + } } } } diff --git a/src/main/java/cn/octopusyan/alistgui/base/BaseTask.java b/gui/src/main/java/cn/octopusyan/alistgui/base/BaseTask.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/base/BaseTask.java rename to gui/src/main/java/cn/octopusyan/alistgui/base/BaseTask.java diff --git a/src/main/java/cn/octopusyan/alistgui/base/BaseViewModel.java b/gui/src/main/java/cn/octopusyan/alistgui/base/BaseViewModel.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/base/BaseViewModel.java rename to gui/src/main/java/cn/octopusyan/alistgui/base/BaseViewModel.java diff --git a/src/main/java/cn/octopusyan/alistgui/config/Constants.java b/gui/src/main/java/cn/octopusyan/alistgui/config/Constants.java similarity index 93% rename from src/main/java/cn/octopusyan/alistgui/config/Constants.java rename to gui/src/main/java/cn/octopusyan/alistgui/config/Constants.java index 7127f24..41f03f0 100644 --- a/src/main/java/cn/octopusyan/alistgui/config/Constants.java +++ b/gui/src/main/java/cn/octopusyan/alistgui/config/Constants.java @@ -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; diff --git a/src/main/java/cn/octopusyan/alistgui/config/Context.java b/gui/src/main/java/cn/octopusyan/alistgui/config/Context.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/config/Context.java rename to gui/src/main/java/cn/octopusyan/alistgui/config/Context.java diff --git a/src/main/java/cn/octopusyan/alistgui/config/I18n.java b/gui/src/main/java/cn/octopusyan/alistgui/config/I18n.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/config/I18n.java rename to gui/src/main/java/cn/octopusyan/alistgui/config/I18n.java diff --git a/src/main/java/cn/octopusyan/alistgui/config/ObservableResourceBundleFactory.java b/gui/src/main/java/cn/octopusyan/alistgui/config/ObservableResourceBundleFactory.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/config/ObservableResourceBundleFactory.java rename to gui/src/main/java/cn/octopusyan/alistgui/config/ObservableResourceBundleFactory.java diff --git a/src/main/java/cn/octopusyan/alistgui/controller/AboutController.java b/gui/src/main/java/cn/octopusyan/alistgui/controller/AboutController.java similarity index 87% rename from src/main/java/cn/octopusyan/alistgui/controller/AboutController.java rename to gui/src/main/java/cn/octopusyan/alistgui/controller/AboutController.java index c2caeb3..282956e 100644 --- a/src/main/java/cn/octopusyan/alistgui/controller/AboutController.java +++ b/gui/src/main/java/cn/octopusyan/alistgui/controller/AboutController.java @@ -1,7 +1,6 @@ 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; @@ -22,16 +21,12 @@ public class AboutController extends BaseController { 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 diff --git a/src/main/java/cn/octopusyan/alistgui/controller/MainController.java b/gui/src/main/java/cn/octopusyan/alistgui/controller/MainController.java similarity index 90% rename from src/main/java/cn/octopusyan/alistgui/controller/MainController.java rename to gui/src/main/java/cn/octopusyan/alistgui/controller/MainController.java index 7e14417..1be9c82 100644 --- a/src/main/java/cn/octopusyan/alistgui/controller/MainController.java +++ b/gui/src/main/java/cn/octopusyan/alistgui/controller/MainController.java @@ -2,7 +2,6 @@ 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; @@ -32,28 +31,20 @@ public class MainController extends BaseController { 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; diff --git a/src/main/java/cn/octopusyan/alistgui/controller/PasswordController.java b/gui/src/main/java/cn/octopusyan/alistgui/controller/PasswordController.java similarity index 96% rename from src/main/java/cn/octopusyan/alistgui/controller/PasswordController.java rename to gui/src/main/java/cn/octopusyan/alistgui/controller/PasswordController.java index ccb5546..d1c1bc9 100644 --- a/src/main/java/cn/octopusyan/alistgui/controller/PasswordController.java +++ b/gui/src/main/java/cn/octopusyan/alistgui/controller/PasswordController.java @@ -4,7 +4,6 @@ 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; @@ -27,14 +26,11 @@ import org.apache.commons.lang3.StringUtils; public class PasswordController extends BaseController { 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; diff --git a/src/main/java/cn/octopusyan/alistgui/controller/RootController.java b/gui/src/main/java/cn/octopusyan/alistgui/controller/RootController.java similarity index 94% rename from src/main/java/cn/octopusyan/alistgui/controller/RootController.java rename to gui/src/main/java/cn/octopusyan/alistgui/controller/RootController.java index efd9e83..bebc442 100644 --- a/src/main/java/cn/octopusyan/alistgui/controller/RootController.java +++ b/gui/src/main/java/cn/octopusyan/alistgui/controller/RootController.java @@ -3,7 +3,6 @@ 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; @@ -41,19 +40,13 @@ public class RootController extends BaseController { // 界面 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(); diff --git a/src/main/java/cn/octopusyan/alistgui/controller/SetupController.java b/gui/src/main/java/cn/octopusyan/alistgui/controller/SetupController.java similarity index 91% rename from src/main/java/cn/octopusyan/alistgui/controller/SetupController.java rename to gui/src/main/java/cn/octopusyan/alistgui/controller/SetupController.java index 1f12631..9aa23a5 100644 --- a/src/main/java/cn/octopusyan/alistgui/controller/SetupController.java +++ b/gui/src/main/java/cn/octopusyan/alistgui/controller/SetupController.java @@ -3,7 +3,6 @@ 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; @@ -31,29 +30,20 @@ public class SetupController extends BaseController 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 themeComboBox; - @I18n(key = "setup.language") public Label languageLabel; public ComboBox languageComboBox; - @I18n(key = "setup.proxy") public Label proxySetupLabel; public ComboBox 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 diff --git a/src/main/java/cn/octopusyan/alistgui/enums/ProxySetup.java b/gui/src/main/java/cn/octopusyan/alistgui/enums/ProxySetup.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/enums/ProxySetup.java rename to gui/src/main/java/cn/octopusyan/alistgui/enums/ProxySetup.java diff --git a/src/main/java/cn/octopusyan/alistgui/manager/AListManager.java b/gui/src/main/java/cn/octopusyan/alistgui/manager/AListManager.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/manager/AListManager.java rename to gui/src/main/java/cn/octopusyan/alistgui/manager/AListManager.java diff --git a/src/main/java/cn/octopusyan/alistgui/manager/ConfigManager.java b/gui/src/main/java/cn/octopusyan/alistgui/manager/ConfigManager.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/manager/ConfigManager.java rename to gui/src/main/java/cn/octopusyan/alistgui/manager/ConfigManager.java diff --git a/src/main/java/cn/octopusyan/alistgui/manager/ConsoleLog.java b/gui/src/main/java/cn/octopusyan/alistgui/manager/ConsoleLog.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/manager/ConsoleLog.java rename to gui/src/main/java/cn/octopusyan/alistgui/manager/ConsoleLog.java diff --git a/src/main/java/cn/octopusyan/alistgui/manager/SystemTrayManager.java b/gui/src/main/java/cn/octopusyan/alistgui/manager/SystemTrayManager.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/manager/SystemTrayManager.java rename to gui/src/main/java/cn/octopusyan/alistgui/manager/SystemTrayManager.java diff --git a/src/main/java/cn/octopusyan/alistgui/manager/http/HttpConfig.java b/gui/src/main/java/cn/octopusyan/alistgui/manager/http/HttpConfig.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/manager/http/HttpConfig.java rename to gui/src/main/java/cn/octopusyan/alistgui/manager/http/HttpConfig.java diff --git a/src/main/java/cn/octopusyan/alistgui/manager/http/HttpUtil.java b/gui/src/main/java/cn/octopusyan/alistgui/manager/http/HttpUtil.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/manager/http/HttpUtil.java rename to gui/src/main/java/cn/octopusyan/alistgui/manager/http/HttpUtil.java diff --git a/src/main/java/cn/octopusyan/alistgui/manager/http/handler/BodyHandler.java b/gui/src/main/java/cn/octopusyan/alistgui/manager/http/handler/BodyHandler.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/manager/http/handler/BodyHandler.java rename to gui/src/main/java/cn/octopusyan/alistgui/manager/http/handler/BodyHandler.java diff --git a/src/main/java/cn/octopusyan/alistgui/manager/thread/ThreadFactory.java b/gui/src/main/java/cn/octopusyan/alistgui/manager/thread/ThreadFactory.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/manager/thread/ThreadFactory.java rename to gui/src/main/java/cn/octopusyan/alistgui/manager/thread/ThreadFactory.java diff --git a/src/main/java/cn/octopusyan/alistgui/manager/thread/ThreadPoolManager.java b/gui/src/main/java/cn/octopusyan/alistgui/manager/thread/ThreadPoolManager.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/manager/thread/ThreadPoolManager.java rename to gui/src/main/java/cn/octopusyan/alistgui/manager/thread/ThreadPoolManager.java diff --git a/src/main/java/cn/octopusyan/alistgui/model/AListConfig.java b/gui/src/main/java/cn/octopusyan/alistgui/model/AListConfig.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/model/AListConfig.java rename to gui/src/main/java/cn/octopusyan/alistgui/model/AListConfig.java diff --git a/src/main/java/cn/octopusyan/alistgui/model/GuiConfig.java b/gui/src/main/java/cn/octopusyan/alistgui/model/GuiConfig.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/model/GuiConfig.java rename to gui/src/main/java/cn/octopusyan/alistgui/model/GuiConfig.java diff --git a/src/main/java/cn/octopusyan/alistgui/model/ProxyInfo.java b/gui/src/main/java/cn/octopusyan/alistgui/model/ProxyInfo.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/model/ProxyInfo.java rename to gui/src/main/java/cn/octopusyan/alistgui/model/ProxyInfo.java diff --git a/src/main/java/cn/octopusyan/alistgui/model/UpgradeConfig.java b/gui/src/main/java/cn/octopusyan/alistgui/model/UpgradeConfig.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/model/UpgradeConfig.java rename to gui/src/main/java/cn/octopusyan/alistgui/model/UpgradeConfig.java diff --git a/src/main/java/cn/octopusyan/alistgui/model/upgrade/AList.java b/gui/src/main/java/cn/octopusyan/alistgui/model/upgrade/AList.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/model/upgrade/AList.java rename to gui/src/main/java/cn/octopusyan/alistgui/model/upgrade/AList.java diff --git a/src/main/java/cn/octopusyan/alistgui/model/upgrade/Gui.java b/gui/src/main/java/cn/octopusyan/alistgui/model/upgrade/Gui.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/model/upgrade/Gui.java rename to gui/src/main/java/cn/octopusyan/alistgui/model/upgrade/Gui.java diff --git a/src/main/java/cn/octopusyan/alistgui/model/upgrade/UpgradeApp.java b/gui/src/main/java/cn/octopusyan/alistgui/model/upgrade/UpgradeApp.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/model/upgrade/UpgradeApp.java rename to gui/src/main/java/cn/octopusyan/alistgui/model/upgrade/UpgradeApp.java diff --git a/src/main/java/cn/octopusyan/alistgui/task/CheckUpdateTask.java b/gui/src/main/java/cn/octopusyan/alistgui/task/CheckUpdateTask.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/task/CheckUpdateTask.java rename to gui/src/main/java/cn/octopusyan/alistgui/task/CheckUpdateTask.java diff --git a/src/main/java/cn/octopusyan/alistgui/task/DownloadTask.java b/gui/src/main/java/cn/octopusyan/alistgui/task/DownloadTask.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/task/DownloadTask.java rename to gui/src/main/java/cn/octopusyan/alistgui/task/DownloadTask.java diff --git a/src/main/java/cn/octopusyan/alistgui/task/ProxyCheckTask.java b/gui/src/main/java/cn/octopusyan/alistgui/task/ProxyCheckTask.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/task/ProxyCheckTask.java rename to gui/src/main/java/cn/octopusyan/alistgui/task/ProxyCheckTask.java diff --git a/src/main/java/cn/octopusyan/alistgui/task/listener/TaskListener.java b/gui/src/main/java/cn/octopusyan/alistgui/task/listener/TaskListener.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/task/listener/TaskListener.java rename to gui/src/main/java/cn/octopusyan/alistgui/task/listener/TaskListener.java diff --git a/src/main/java/cn/octopusyan/alistgui/util/DownloadUtil.java b/gui/src/main/java/cn/octopusyan/alistgui/util/DownloadUtil.java similarity index 96% rename from src/main/java/cn/octopusyan/alistgui/util/DownloadUtil.java rename to gui/src/main/java/cn/octopusyan/alistgui/util/DownloadUtil.java index d74543d..089bd22 100644 --- a/src/main/java/cn/octopusyan/alistgui/util/DownloadUtil.java +++ b/gui/src/main/java/cn/octopusyan/alistgui/util/DownloadUtil.java @@ -62,6 +62,10 @@ 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()); @@ -93,6 +97,6 @@ public class DownloadUtil { }); // 解压完成后删除 - FileUtil.del(file); + if (del) FileUtil.del(file); } } diff --git a/src/main/java/cn/octopusyan/alistgui/util/FxmlUtil.java b/gui/src/main/java/cn/octopusyan/alistgui/util/FxmlUtil.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/util/FxmlUtil.java rename to gui/src/main/java/cn/octopusyan/alistgui/util/FxmlUtil.java diff --git a/src/main/java/cn/octopusyan/alistgui/util/JsonUtil.java b/gui/src/main/java/cn/octopusyan/alistgui/util/JsonUtil.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/util/JsonUtil.java rename to gui/src/main/java/cn/octopusyan/alistgui/util/JsonUtil.java diff --git a/src/main/java/cn/octopusyan/alistgui/util/ProcessesUtil.java b/gui/src/main/java/cn/octopusyan/alistgui/util/ProcessesUtil.java similarity index 97% rename from src/main/java/cn/octopusyan/alistgui/util/ProcessesUtil.java rename to gui/src/main/java/cn/octopusyan/alistgui/util/ProcessesUtil.java index bae8336..9937ade 100644 --- a/src/main/java/cn/octopusyan/alistgui/util/ProcessesUtil.java +++ b/gui/src/main/java/cn/octopusyan/alistgui/util/ProcessesUtil.java @@ -53,7 +53,7 @@ public class ProcessesUtil { commandLine = CommandLine.parse(command); int execute = 0; try { - execute = executor.execute(commandLine); + executor.execute(commandLine, new DefaultExecuteResultHandler()); } catch (Exception e) { log.error("exec", e); } diff --git a/src/main/java/cn/octopusyan/alistgui/util/PropertiesUtils.java b/gui/src/main/java/cn/octopusyan/alistgui/util/PropertiesUtils.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/util/PropertiesUtils.java rename to gui/src/main/java/cn/octopusyan/alistgui/util/PropertiesUtils.java diff --git a/src/main/java/cn/octopusyan/alistgui/util/Registry.java b/gui/src/main/java/cn/octopusyan/alistgui/util/Registry.java similarity index 96% rename from src/main/java/cn/octopusyan/alistgui/util/Registry.java rename to gui/src/main/java/cn/octopusyan/alistgui/util/Registry.java index f370e9d..cf58ca6 100644 --- a/src/main/java/cn/octopusyan/alistgui/util/Registry.java +++ b/gui/src/main/java/cn/octopusyan/alistgui/util/Registry.java @@ -1,5 +1,7 @@ package cn.octopusyan.alistgui.util; +import lombok.Getter; + /** * 注册表编辑 * @@ -45,6 +47,7 @@ public class Registry { UNLOAD, } + @Getter public enum Root { HKCR("HKEY_CLASSES_ROOT"), HKCU("HKEY_CURRENT_USER"), @@ -59,9 +62,6 @@ public class Registry { this.path = path; } - public String getPath() { - return path; - } } public enum DataType { diff --git a/src/main/java/cn/octopusyan/alistgui/util/ViewUtil.java b/gui/src/main/java/cn/octopusyan/alistgui/util/ViewUtil.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/util/ViewUtil.java rename to gui/src/main/java/cn/octopusyan/alistgui/util/ViewUtil.java diff --git a/src/main/java/cn/octopusyan/alistgui/view/PopupMenu.java b/gui/src/main/java/cn/octopusyan/alistgui/view/PopupMenu.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/view/PopupMenu.java rename to gui/src/main/java/cn/octopusyan/alistgui/view/PopupMenu.java diff --git a/src/main/java/cn/octopusyan/alistgui/view/ProxySetupCell.java b/gui/src/main/java/cn/octopusyan/alistgui/view/ProxySetupCell.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/view/ProxySetupCell.java rename to gui/src/main/java/cn/octopusyan/alistgui/view/ProxySetupCell.java diff --git a/src/main/java/cn/octopusyan/alistgui/view/alert/AlertUtil.java b/gui/src/main/java/cn/octopusyan/alistgui/view/alert/AlertUtil.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/view/alert/AlertUtil.java rename to gui/src/main/java/cn/octopusyan/alistgui/view/alert/AlertUtil.java diff --git a/src/main/java/cn/octopusyan/alistgui/view/alert/builder/AlertBuilder.java b/gui/src/main/java/cn/octopusyan/alistgui/view/alert/builder/AlertBuilder.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/view/alert/builder/AlertBuilder.java rename to gui/src/main/java/cn/octopusyan/alistgui/view/alert/builder/AlertBuilder.java diff --git a/src/main/java/cn/octopusyan/alistgui/view/alert/builder/ChoiceBuilder.java b/gui/src/main/java/cn/octopusyan/alistgui/view/alert/builder/ChoiceBuilder.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/view/alert/builder/ChoiceBuilder.java rename to gui/src/main/java/cn/octopusyan/alistgui/view/alert/builder/ChoiceBuilder.java diff --git a/src/main/java/cn/octopusyan/alistgui/view/alert/builder/DefaultBuilder.java b/gui/src/main/java/cn/octopusyan/alistgui/view/alert/builder/DefaultBuilder.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/view/alert/builder/DefaultBuilder.java rename to gui/src/main/java/cn/octopusyan/alistgui/view/alert/builder/DefaultBuilder.java diff --git a/src/main/java/cn/octopusyan/alistgui/view/alert/builder/ProgressBuilder.java b/gui/src/main/java/cn/octopusyan/alistgui/view/alert/builder/ProgressBuilder.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/view/alert/builder/ProgressBuilder.java rename to gui/src/main/java/cn/octopusyan/alistgui/view/alert/builder/ProgressBuilder.java diff --git a/src/main/java/cn/octopusyan/alistgui/view/alert/builder/TextInputBuilder.java b/gui/src/main/java/cn/octopusyan/alistgui/view/alert/builder/TextInputBuilder.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/view/alert/builder/TextInputBuilder.java rename to gui/src/main/java/cn/octopusyan/alistgui/view/alert/builder/TextInputBuilder.java diff --git a/src/main/java/cn/octopusyan/alistgui/viewModel/AboutViewModule.java b/gui/src/main/java/cn/octopusyan/alistgui/viewModel/AboutViewModule.java similarity index 92% rename from src/main/java/cn/octopusyan/alistgui/viewModel/AboutViewModule.java rename to gui/src/main/java/cn/octopusyan/alistgui/viewModel/AboutViewModule.java index c36fda3..0a0663f 100644 --- a/src/main/java/cn/octopusyan/alistgui/viewModel/AboutViewModule.java +++ b/gui/src/main/java/cn/octopusyan/alistgui/viewModel/AboutViewModule.java @@ -1,6 +1,5 @@ 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; @@ -142,24 +141,20 @@ public class AboutViewModule extends BaseViewModel { if (upgrade) DownloadUtil.startDownload(app, newVersion, () -> { - // 下载完成后,解压并删除文件 - DownloadUtil.unzip(app); - - // 解压后 Platform.runLater(() -> { switch (app) { case AList _ -> { + // 下载完成后,解压并删除文件 + DownloadUtil.unzip(app); // 设置应用版本 aListVersion.setValue(aListNewVersion.getValue()); AListManager.restart(); } case Gui _ -> { log.info(STR."guiNewVersion => \{guiNewVersion.get()}"); - // 重启 - Platform.setImplicitExit(true); - Application.getPrimaryStage().close(); - - ProcessesUtil.init(Constants.DATA_DIR_PATH).exec(STR."\{Constants.APP_NAME}.exe"); + // 启动升级程序 + ProcessesUtil.init(Constants.DATA_DIR_PATH).exec("upgrade.exe"); + Platform.exit(); } default -> throw new IllegalStateException(STR."Unexpected value: \{app}"); } diff --git a/src/main/java/cn/octopusyan/alistgui/viewModel/AdminPanelViewModel.java b/gui/src/main/java/cn/octopusyan/alistgui/viewModel/AdminPanelViewModel.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/viewModel/AdminPanelViewModel.java rename to gui/src/main/java/cn/octopusyan/alistgui/viewModel/AdminPanelViewModel.java diff --git a/src/main/java/cn/octopusyan/alistgui/viewModel/MainViewModel.java b/gui/src/main/java/cn/octopusyan/alistgui/viewModel/MainViewModel.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/viewModel/MainViewModel.java rename to gui/src/main/java/cn/octopusyan/alistgui/viewModel/MainViewModel.java diff --git a/src/main/java/cn/octopusyan/alistgui/viewModel/RootViewModel.java b/gui/src/main/java/cn/octopusyan/alistgui/viewModel/RootViewModel.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/viewModel/RootViewModel.java rename to gui/src/main/java/cn/octopusyan/alistgui/viewModel/RootViewModel.java diff --git a/src/main/java/cn/octopusyan/alistgui/viewModel/SetupViewModel.java b/gui/src/main/java/cn/octopusyan/alistgui/viewModel/SetupViewModel.java similarity index 100% rename from src/main/java/cn/octopusyan/alistgui/viewModel/SetupViewModel.java rename to gui/src/main/java/cn/octopusyan/alistgui/viewModel/SetupViewModel.java diff --git a/src/main/java/module-info.java b/gui/src/main/java/module-info.java similarity index 95% rename from src/main/java/module-info.java rename to gui/src/main/java/module-info.java index 9d4dbf6..68949db 100644 --- a/src/main/java/module-info.java +++ b/gui/src/main/java/module-info.java @@ -24,4 +24,5 @@ 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; } \ No newline at end of file diff --git a/src/main/resources/application.properties b/gui/src/main/resources/application.properties similarity index 100% rename from src/main/resources/application.properties rename to gui/src/main/resources/application.properties diff --git a/src/main/resources/assets/logo-about.png b/gui/src/main/resources/assets/logo-about.png similarity index 100% rename from src/main/resources/assets/logo-about.png rename to gui/src/main/resources/assets/logo-about.png diff --git a/src/main/resources/assets/logo-disabled.png b/gui/src/main/resources/assets/logo-disabled.png similarity index 100% rename from src/main/resources/assets/logo-disabled.png rename to gui/src/main/resources/assets/logo-disabled.png diff --git a/src/main/resources/assets/logo.png b/gui/src/main/resources/assets/logo.png similarity index 100% rename from src/main/resources/assets/logo.png rename to gui/src/main/resources/assets/logo.png diff --git a/src/main/resources/assets/logo.svg b/gui/src/main/resources/assets/logo.svg similarity index 100% rename from src/main/resources/assets/logo.svg rename to gui/src/main/resources/assets/logo.svg diff --git a/src/main/resources/assets/windows/alist-gui.ico b/gui/src/main/resources/assets/windows/alist-gui.ico similarity index 100% rename from src/main/resources/assets/windows/alist-gui.ico rename to gui/src/main/resources/assets/windows/alist-gui.ico diff --git a/src/main/resources/css/about-view.scss b/gui/src/main/resources/css/about-view.scss similarity index 100% rename from src/main/resources/css/about-view.scss rename to gui/src/main/resources/css/about-view.scss diff --git a/src/main/resources/css/admin-panel.scss b/gui/src/main/resources/css/admin-panel.scss similarity index 100% rename from src/main/resources/css/admin-panel.scss rename to gui/src/main/resources/css/admin-panel.scss diff --git a/src/main/resources/css/main-view.scss b/gui/src/main/resources/css/main-view.scss similarity index 100% rename from src/main/resources/css/main-view.scss rename to gui/src/main/resources/css/main-view.scss diff --git a/src/main/resources/css/root-view.scss b/gui/src/main/resources/css/root-view.scss similarity index 100% rename from src/main/resources/css/root-view.scss rename to gui/src/main/resources/css/root-view.scss diff --git a/src/main/resources/css/root.scss b/gui/src/main/resources/css/root.scss similarity index 100% rename from src/main/resources/css/root.scss rename to gui/src/main/resources/css/root.scss diff --git a/src/main/resources/css/setup-view.scss b/gui/src/main/resources/css/setup-view.scss similarity index 100% rename from src/main/resources/css/setup-view.scss rename to gui/src/main/resources/css/setup-view.scss diff --git a/src/main/resources/fxml/about-view.fxml b/gui/src/main/resources/fxml/about-view.fxml similarity index 100% rename from src/main/resources/fxml/about-view.fxml rename to gui/src/main/resources/fxml/about-view.fxml diff --git a/src/main/resources/fxml/admin-panel.fxml b/gui/src/main/resources/fxml/admin-panel.fxml similarity index 100% rename from src/main/resources/fxml/admin-panel.fxml rename to gui/src/main/resources/fxml/admin-panel.fxml diff --git a/src/main/resources/fxml/main-view.fxml b/gui/src/main/resources/fxml/main-view.fxml similarity index 100% rename from src/main/resources/fxml/main-view.fxml rename to gui/src/main/resources/fxml/main-view.fxml diff --git a/src/main/resources/fxml/root-view.fxml b/gui/src/main/resources/fxml/root-view.fxml similarity index 100% rename from src/main/resources/fxml/root-view.fxml rename to gui/src/main/resources/fxml/root-view.fxml diff --git a/src/main/resources/fxml/setup-view.fxml b/gui/src/main/resources/fxml/setup-view.fxml similarity index 100% rename from src/main/resources/fxml/setup-view.fxml rename to gui/src/main/resources/fxml/setup-view.fxml diff --git a/src/main/resources/language/language.properties b/gui/src/main/resources/language/language.properties similarity index 100% rename from src/main/resources/language/language.properties rename to gui/src/main/resources/language/language.properties diff --git a/src/main/resources/language/language_en.properties b/gui/src/main/resources/language/language_en.properties similarity index 100% rename from src/main/resources/language/language_en.properties rename to gui/src/main/resources/language/language_en.properties diff --git a/src/main/resources/language/language_zh_CN.properties b/gui/src/main/resources/language/language_zh_CN.properties similarity index 100% rename from src/main/resources/language/language_zh_CN.properties rename to gui/src/main/resources/language/language_zh_CN.properties diff --git a/src/main/resources/logback.xml b/gui/src/main/resources/logback.xml similarity index 100% rename from src/main/resources/logback.xml rename to gui/src/main/resources/logback.xml diff --git a/pom.xml b/pom.xml index 8ef597e..27fb5ed 100644 --- a/pom.xml +++ b/pom.xml @@ -6,8 +6,9 @@ cn.octopusyan alist-gui - 1.0.2 + 1.0.1 alist-gui + pom octopus_yan @@ -17,6 +18,11 @@ 2024 AList GUI + + upgrade + gui + + 21 21 @@ -24,9 +30,7 @@ UTF-8 UTF-8 - cn.octopusyan.alistgui.AppLauncher - ${project.basedir}/src/main/resources/css - ${project.basedir}/target/classes/css + 1.0.1 5.10.0 21.0.4 @@ -42,261 +46,99 @@ 1.0.1 - - - - org.openjfx - javafx-controls - ${javafx.version} - - - org.openjfx - javafx-fxml - ${javafx.version} - + - - - io.github.mkpaz - atlantafx-base - 2.0.1 - + - - - - org.slf4j - slf4j-api - ${slf4j.version} - - - ch.qos.logback - logback-classic - ${logback.version} - - - ch.qos.logback - logback-core - ${logback.version} - - - - - - org.apache.commons - commons-lang3 - ${common-lang3.version} - - - - org.apache.commons - commons-exec - ${common-exec.version} - - - - - cn.hutool - hutool-core - ${hutool.version} - - - - - org.projectlombok - lombok - ${lombok.version} - - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - ${jackson.version} - - - - - org.kordamp.ikonli - ikonli-javafx - ${ikonli.version} - - - org.kordamp.ikonli - ikonli-fontawesome-pack - ${ikonli.version} - - - com.gluonhq - emoji - ${gluonhq-emoji.version} - - - - - - - nexus - nexus-snapshot-repository - https://oss.sonatype.org/content/repositories/snapshots - - true - always - - - false - - - - - - - - src/main/resources - true - - css/*.scss - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.13.0 - - 21 - 21 - --enable-preview - UTF-8 - - - org.projectlombok - lombok - ${lombok.version} - - - - - - - - us.hebi.sass - sass-cli-maven-plugin - 1.0.3 - - 1.78.0 - - ${cssSrcPath}/root.scss:${cssTargetPath}/root.css - ${cssSrcPath}/root-view.scss:${cssTargetPath}/root-view.css - ${cssSrcPath}/main-view.scss:${cssTargetPath}/main-view.css - ${cssSrcPath}/setup-view.scss:${cssTargetPath}/setup-view.css - ${cssSrcPath}/about-view.scss:${cssTargetPath}/about-view.css - ${cssSrcPath}/admin-panel.scss:${cssTargetPath}/admin-panel.css - --no-source-map - - - - - sass-exec - generate-resources - - run - - - - - - + + org.openjfx - javafx-maven-plugin - 0.0.8 - - true - 2 - true - true - alistgui - app - app - cn.octopusyan.alistgui/${exec.mainClass} - - - - - default-cli - - true - 2 - true - true - alist-gui - app - app - cn.octopusyan.alistgui/${exec.mainClass} - - - - - - - - + javafx-controls + ${javafx.version} + + + org.openjfx + javafx-fxml + ${javafx.version} + - - - io.github.fvarrui - javapackager - 1.7.7-SNAPSHOT - - ${exec.mainClass} - true - false - true - ${project.basedir}/src/main/resources/assets - - --enable-preview - -Xmx100m - - - - - windows - package - - package - - - windows - ${project.name}-windows - true - - gui - false - - - - - windows-nojre - package - - package - - - ${project.name}-windows-nojre - windows - true - false - - gui - false - - - - - - - + + + io.github.mkpaz + atlantafx-base + 2.0.1 + + + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + ch.qos.logback + logback-core + ${logback.version} + + + + + + org.apache.commons + commons-lang3 + ${common-lang3.version} + + + + org.apache.commons + commons-exec + ${common-exec.version} + + + + + cn.hutool + hutool-core + ${hutool.version} + + + + + org.projectlombok + lombok + ${lombok.version} + + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + ${jackson.version} + + + + + org.kordamp.ikonli + ikonli-javafx + ${ikonli.version} + + + org.kordamp.ikonli + ikonli-fontawesome-pack + ${ikonli.version} + + + com.gluonhq + emoji + ${gluonhq-emoji.version} + + + + \ No newline at end of file diff --git a/upgrade/pom.xml b/upgrade/pom.xml new file mode 100644 index 0000000..caf4cca --- /dev/null +++ b/upgrade/pom.xml @@ -0,0 +1,174 @@ + + + 4.0.0 + + + cn.octopusyan + alist-gui + 1.0.1 + + + upgrade + ${parent.version} + upgrade + + + 21 + 21 + 21 + UTF-8 + UTF-8 + + cn.octopusyan.upgrade.AppLauncher + + + + + + org.openjfx + javafx-controls + + + org.openjfx + javafx-fxml + + + + + io.github.mkpaz + atlantafx-base + + + + cn.hutool + hutool-core + + + org.apache.commons + commons-lang3 + + + org.projectlombok + lombok + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + 21 + 21 + UTF-8 + + + org.projectlombok + lombok + ${lombok.version} + + + + + + + org.openjfx + javafx-maven-plugin + 0.0.8 + + true + 2 + true + true + upgrade + app + app + cn.octopusyan.upgrade/${exec.mainClass} + + + + + default-cli + + true + 2 + true + true + upgrade + app + app + cn.octopusyan.upgrade/${exec.mainClass} + + + + + + + + io.github.fvarrui + javapackager + 1.7.7-SNAPSHOT + + ${exec.mainClass} + true + false + true + + -Xmx100m + + + + + windows + package + + package + + + windows + false + + gui + false + + + + + + + + org.apache.maven.plugins + maven-resources-plugin + + + copy-resources + package + + copy-resources + + + UTF-8 + + ../gui/src/main/resources/static + + + + ./target/upgrade + + upgrade.exe + + + + + + + + + + + \ No newline at end of file diff --git a/upgrade/src/main/java/cn/octopusyan/upgrade/AppLauncher.java b/upgrade/src/main/java/cn/octopusyan/upgrade/AppLauncher.java new file mode 100644 index 0000000..c8b42b3 --- /dev/null +++ b/upgrade/src/main/java/cn/octopusyan/upgrade/AppLauncher.java @@ -0,0 +1,13 @@ +package cn.octopusyan.upgrade; + +/** + * 启动类 + * + * @author octopus_yan@foxmail.com + */ +public class AppLauncher { + + public static void main(String[] args) { + Application.launch(Application.class, args); + } +} diff --git a/upgrade/src/main/java/cn/octopusyan/upgrade/Application.java b/upgrade/src/main/java/cn/octopusyan/upgrade/Application.java new file mode 100644 index 0000000..1f42806 --- /dev/null +++ b/upgrade/src/main/java/cn/octopusyan/upgrade/Application.java @@ -0,0 +1,35 @@ +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); + } +} \ No newline at end of file diff --git a/upgrade/src/main/java/cn/octopusyan/upgrade/alert/AlertUtil.java b/upgrade/src/main/java/cn/octopusyan/upgrade/alert/AlertUtil.java new file mode 100644 index 0000000..de41bcd --- /dev/null +++ b/upgrade/src/main/java/cn/octopusyan/upgrade/alert/AlertUtil.java @@ -0,0 +1,75 @@ +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); + } + + /** + * 自定义确认对话框

+ * + * @param buttons "Cancel" OR "取消" 为取消按钮 + */ + 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); + } +} diff --git a/upgrade/src/main/java/cn/octopusyan/upgrade/alert/builder/AlertBuilder.java b/upgrade/src/main/java/cn/octopusyan/upgrade/alert/builder/AlertBuilder.java new file mode 100644 index 0000000..73885cc --- /dev/null +++ b/upgrade/src/main/java/cn/octopusyan/upgrade/alert/builder/AlertBuilder.java @@ -0,0 +1,108 @@ +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 { + + 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 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 result = dialog.showAndWait(); + result.ifPresent(r -> listener.onClicked(r.getText())); + } + + /** + * AlertUtil.confirm + */ + public void show(AlertUtil.OnChoseListener listener) { + Optional result = dialog.showAndWait(); + result.ifPresent(r -> { + if (r == ButtonType.OK) { + listener.confirm(); + } else { + listener.cancelOrClose(r); + } + }); + } +} \ No newline at end of file diff --git a/upgrade/src/main/java/cn/octopusyan/upgrade/alert/builder/BaseBuilder.java b/upgrade/src/main/java/cn/octopusyan/upgrade/alert/builder/BaseBuilder.java new file mode 100644 index 0000000..151ce3b --- /dev/null +++ b/upgrade/src/main/java/cn/octopusyan/upgrade/alert/builder/BaseBuilder.java @@ -0,0 +1,44 @@ +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, 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(); + } +} diff --git a/upgrade/src/main/java/cn/octopusyan/upgrade/util/FxmlUtil.java b/upgrade/src/main/java/cn/octopusyan/upgrade/util/FxmlUtil.java new file mode 100644 index 0000000..d9bd0c5 --- /dev/null +++ b/upgrade/src/main/java/cn/octopusyan/upgrade/util/FxmlUtil.java @@ -0,0 +1,19 @@ +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 + ); + } +} diff --git a/upgrade/src/main/java/cn/octopusyan/upgrade/view/HelloController.java b/upgrade/src/main/java/cn/octopusyan/upgrade/view/HelloController.java new file mode 100644 index 0000000..2c7397c --- /dev/null +++ b/upgrade/src/main/java/cn/octopusyan/upgrade/view/HelloController.java @@ -0,0 +1,83 @@ +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); + } +} \ No newline at end of file diff --git a/upgrade/src/main/java/module-info.java b/upgrade/src/main/java/module-info.java new file mode 100644 index 0000000..442f919 --- /dev/null +++ b/upgrade/src/main/java/module-info.java @@ -0,0 +1,16 @@ +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; +} \ No newline at end of file diff --git a/upgrade/src/main/resources/fxml/hello-view.fxml b/upgrade/src/main/resources/fxml/hello-view.fxml new file mode 100644 index 0000000..4ad20ba --- /dev/null +++ b/upgrade/src/main/resources/fxml/hello-view.fxml @@ -0,0 +1,14 @@ + + + + + + + + + +