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
- --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
+ 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 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/upgrade/src/main/resources/language/language.properties b/upgrade/src/main/resources/language/language.properties
new file mode 100644
index 0000000..c0f8d4d
--- /dev/null
+++ b/upgrade/src/main/resources/language/language.properties
@@ -0,0 +1,7 @@
+exit=\u9000\u51FA
+title=\u66F4\u65B0
+update=\u66F4\u65B0
+
+
+
+
diff --git a/upgrade/src/main/resources/language/language_en.properties b/upgrade/src/main/resources/language/language_en.properties
new file mode 100644
index 0000000..c94ddea
--- /dev/null
+++ b/upgrade/src/main/resources/language/language_en.properties
@@ -0,0 +1,6 @@
+exit=Exit
+title=Upgrade App
+update=Upgrade
+
+
+
diff --git a/upgrade/src/main/resources/language/language_zh_CN.properties b/upgrade/src/main/resources/language/language_zh_CN.properties
new file mode 100644
index 0000000..b155a5f
--- /dev/null
+++ b/upgrade/src/main/resources/language/language_zh_CN.properties
@@ -0,0 +1,6 @@
+exit=\u9000\u51FA
+title=\u66F4\u65B0
+update=\u66F4\u65B0
+
+
+