diff --git a/pom.xml b/pom.xml
index 51bbb7b..3df4e31 100644
--- a/pom.xml
+++ b/pom.xml
@@ -258,7 +258,6 @@
--enable-preview
-Xmx100m
-
@@ -270,6 +269,7 @@
windows
+ ${project.name}-windows
true
gui
@@ -277,6 +277,23 @@
+
+ bundling-for-windows-nojre
+ package
+
+ package
+
+
+ ${project.name}-windows-nojre
+ windows
+ true
+ false
+
+ gui
+ false
+
+
+
diff --git a/src/main/java/cn/octopusyan/alistgui/controller/AboutController.java b/src/main/java/cn/octopusyan/alistgui/controller/AboutController.java
index a012854..c2caeb3 100644
--- a/src/main/java/cn/octopusyan/alistgui/controller/AboutController.java
+++ b/src/main/java/cn/octopusyan/alistgui/controller/AboutController.java
@@ -3,7 +3,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.view.alert.AlertUtil;
import cn.octopusyan.alistgui.viewModel.AboutViewModule;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
@@ -60,8 +59,7 @@ public class AboutController extends BaseController {
}
public void checkGuiUpdate() {
- // TODO 检查 gui 版本
- AlertUtil.info("待开发。。。").show();
+ viewModel.checkUpdate(ConfigManager.gui());
}
}
diff --git a/src/main/java/cn/octopusyan/alistgui/manager/AListManager.java b/src/main/java/cn/octopusyan/alistgui/manager/AListManager.java
index 5312a06..9307628 100644
--- a/src/main/java/cn/octopusyan/alistgui/manager/AListManager.java
+++ b/src/main/java/cn/octopusyan/alistgui/manager/AListManager.java
@@ -205,7 +205,7 @@ public class AListManager {
}
var task = new CheckUpdateTask(ConfigManager.aList());
- task.onListen(new TaskListener.UpgradeUpgradeListener(task) {
+ task.onListen(new TaskListener.UpgradeListener(task) {
@Override
public void onChecked(boolean hasUpgrade, String version) {
Platform.runLater(() -> showDownload(version));
diff --git a/src/main/java/cn/octopusyan/alistgui/model/upgrade/Gui.java b/src/main/java/cn/octopusyan/alistgui/model/upgrade/Gui.java
index 0dac232..49a332a 100644
--- a/src/main/java/cn/octopusyan/alistgui/model/upgrade/Gui.java
+++ b/src/main/java/cn/octopusyan/alistgui/model/upgrade/Gui.java
@@ -10,18 +10,12 @@ import lombok.Data;
@Data
public class Gui implements UpgradeApp {
@JsonIgnore
- private final String owner = "alist-org";
+ private final String owner = "octopusYan";
+
@JsonIgnore
- private final String repo = "alist";
+ private final String repo = "alist-gui";
+
+ private String releaseFile = "alist-gui-windows-nojre.zip";
- private String releaseFile = "alist-gui-{version}-windows.zip";
private String version = PropertiesUtils.getInstance().getProperty("app.version");
-
- public String getReleaseFile() {
- return getReleaseFile(version);
- }
-
- public String getReleaseFile(String version) {
- return releaseFile.replace("{version}", version);
- }
}
diff --git a/src/main/java/cn/octopusyan/alistgui/task/DownloadTask.java b/src/main/java/cn/octopusyan/alistgui/task/DownloadTask.java
index 6a8104e..b15734a 100644
--- a/src/main/java/cn/octopusyan/alistgui/task/DownloadTask.java
+++ b/src/main/java/cn/octopusyan/alistgui/task/DownloadTask.java
@@ -1,7 +1,6 @@
package cn.octopusyan.alistgui.task;
import cn.octopusyan.alistgui.base.BaseTask;
-import cn.octopusyan.alistgui.config.Constants;
import cn.octopusyan.alistgui.manager.http.HttpUtil;
import lombok.extern.slf4j.Slf4j;
@@ -13,10 +12,12 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class DownloadTask extends BaseTask {
private final String downloadUrl;
+ private final String savePath;
- public DownloadTask(String downloadUrl) {
+ public DownloadTask(String downloadUrl, String savePath) {
super(STR."Download \{downloadUrl}");
this.downloadUrl = downloadUrl;
+ this.savePath = savePath;
}
public void onListen(DownloadListener listener) {
@@ -27,7 +28,7 @@ public class DownloadTask extends BaseTask {
protected void task() throws Exception {
HttpUtil.getInstance().download(
downloadUrl,
- Constants.BIN_DIR_PATH,
+ savePath,
listener instanceof DownloadListener ? ((DownloadListener) listener)::onProgress : null
);
}
diff --git a/src/main/java/cn/octopusyan/alistgui/task/listener/TaskListener.java b/src/main/java/cn/octopusyan/alistgui/task/listener/TaskListener.java
index 03088e4..508574a 100644
--- a/src/main/java/cn/octopusyan/alistgui/task/listener/TaskListener.java
+++ b/src/main/java/cn/octopusyan/alistgui/task/listener/TaskListener.java
@@ -89,8 +89,8 @@ public abstract class TaskListener implements BaseTask.Listener {
/**
* 检查更新监听默认实现
*/
- public static abstract class UpgradeUpgradeListener extends TaskListener implements CheckUpdateTask.UpgradeListener {
- public UpgradeUpgradeListener(BaseTask task) {
+ public static abstract class UpgradeListener extends TaskListener implements CheckUpdateTask.UpgradeListener {
+ public UpgradeListener(BaseTask task) {
super(task);
}
diff --git a/src/main/java/cn/octopusyan/alistgui/util/DownloadUtil.java b/src/main/java/cn/octopusyan/alistgui/util/DownloadUtil.java
index 406c67e..e9db4f4 100644
--- a/src/main/java/cn/octopusyan/alistgui/util/DownloadUtil.java
+++ b/src/main/java/cn/octopusyan/alistgui/util/DownloadUtil.java
@@ -7,6 +7,7 @@ import cn.hutool.core.util.ZipUtil;
import cn.octopusyan.alistgui.config.Constants;
import cn.octopusyan.alistgui.manager.ConsoleLog;
import cn.octopusyan.alistgui.model.upgrade.AList;
+import cn.octopusyan.alistgui.model.upgrade.Gui;
import cn.octopusyan.alistgui.model.upgrade.UpgradeApp;
import cn.octopusyan.alistgui.task.DownloadTask;
import cn.octopusyan.alistgui.task.listener.TaskListener;
@@ -24,7 +25,6 @@ import java.util.zip.ZipFile;
@Slf4j
public class DownloadUtil {
-
/**
* 下载文件
*
@@ -32,7 +32,12 @@ public class DownloadUtil {
* @param version 下载版本
*/
public static DownloadTask startDownload(UpgradeApp app, String version, Runnable runnable) {
- var task = new DownloadTask(app.getDownloadUrl(version));
+ var parentPath = switch (app) {
+ case AList _ -> Constants.BIN_DIR_PATH;
+ case Gui _ -> Constants.DATA_DIR_PATH;
+ default -> throw new IllegalStateException(STR."Unexpected value: \{app}");
+ };
+ var task = new DownloadTask(app.getDownloadUrl(version), parentPath);
task.onListen(new TaskListener.DownloadListener(task) {
@Override
@@ -64,6 +69,11 @@ public class DownloadUtil {
path = StrUtil.replace(path, "*", "_");
}
+ // 打包后文件都在alist-gui文件夹下,解压时去掉
+ if (app instanceof Gui) {
+ path = path.replaceFirst(Constants.APP_NAME, "");
+ }
+
final File outItemFile = FileUtil.file(parentPath, path);
if (zipEntry.isDirectory()) {
// 目录
diff --git a/src/main/java/cn/octopusyan/alistgui/viewModel/AboutViewModule.java b/src/main/java/cn/octopusyan/alistgui/viewModel/AboutViewModule.java
index c5dbdef..c36fda3 100644
--- a/src/main/java/cn/octopusyan/alistgui/viewModel/AboutViewModule.java
+++ b/src/main/java/cn/octopusyan/alistgui/viewModel/AboutViewModule.java
@@ -1,14 +1,19 @@
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;
+import cn.octopusyan.alistgui.manager.AListManager;
import cn.octopusyan.alistgui.manager.ConfigManager;
import cn.octopusyan.alistgui.manager.ConsoleLog;
import cn.octopusyan.alistgui.model.upgrade.AList;
+import cn.octopusyan.alistgui.model.upgrade.Gui;
import cn.octopusyan.alistgui.model.upgrade.UpgradeApp;
import cn.octopusyan.alistgui.task.CheckUpdateTask;
import cn.octopusyan.alistgui.task.listener.TaskListener;
import cn.octopusyan.alistgui.util.DownloadUtil;
+import cn.octopusyan.alistgui.util.ProcessesUtil;
import cn.octopusyan.alistgui.view.alert.AlertUtil;
import cn.octopusyan.alistgui.view.alert.builder.AlertBuilder;
import javafx.application.Platform;
@@ -61,52 +66,22 @@ public class AboutViewModule extends BaseViewModel {
* 检查更新
*/
public void checkUpdate(UpgradeApp app) {
-
// 检查任务
- startUpgrade(app, () -> {
- // 判断 检查的应用
- boolean tag = app instanceof AList;
-
- boolean upgrade = tag ? aListUpgrade.get() : guiUpgrade.get();
- String version = tag ? aListVersion.get() : guiVersion.get();
- String newVersion = tag ? aListNewVersion.get() : guiNewVersion.get();
- String title = Context.getLanguageBinding(STR."about.\{tag ? "alist" : "app"}.update").getValue();
- String currentLabel = Context.getLanguageBinding("update.current").get();
- String newLabel = Context.getLanguageBinding("update.remote").get();
- String header = Context.getLanguageBinding(STR."update.upgrade.\{upgrade ? "new" : "not"}").get();
-
- // 版本检查消息
- String msg = STR."\{app.getRepo()}\{upgrade ? "" : STR." \{version}"} \{header} \{upgrade ? newVersion : ""}";
- log.info(msg);
- ConsoleLog.info(msg);
-
- // 弹窗
- AlertBuilder builder = upgrade ? AlertUtil.confirm() : AlertUtil.info();
- builder.title(title)
- .header(header)
- .content(STR."""
- \{currentLabel} : \{version}
- \{newLabel} : \{newVersion}
- """)
- .show(() -> {
- // 可升级,且点击了确定后,开始下载任务
- if (upgrade)
- DownloadUtil.startDownload(app, newVersion, () -> {
- // 下载完成后,解压并删除文件
- DownloadUtil.unzip(app);
- // 设置应用版本
- Platform.runLater(() -> aListVersion.setValue(aListNewVersion.getValue()));
- }).execute();
- });
- });
+ startUpgrade(app, () -> onChecked(app));
}
+ /**
+ * 开始检查更新
+ *
+ * @param app 更新的应用
+ * @param runnable 检查后执行的任务
+ */
private void startUpgrade(UpgradeApp app, Runnable runnable) {
// 检查更新的任务
var task = new CheckUpdateTask(app);
// 任务监听
- task.onListen(new TaskListener.UpgradeUpgradeListener(task) {
+ task.onListen(new TaskListener.UpgradeListener(task) {
@Override
protected void onSucceed() {
@@ -135,4 +110,62 @@ public class AboutViewModule extends BaseViewModel {
// 执行任务
task.execute();
}
+
+
+ private void onChecked(UpgradeApp app) {
+ // 判断 检查的应用
+ boolean tag = app instanceof AList;
+
+ boolean upgrade = tag ? aListUpgrade.get() : guiUpgrade.get();
+ String version = tag ? aListVersion.get() : guiVersion.get();
+ String newVersion = tag ? aListNewVersion.get() : guiNewVersion.get();
+ String title = Context.getLanguageBinding(STR."about.\{tag ? "alist" : "app"}.update").getValue();
+ String currentLabel = Context.getLanguageBinding("update.current").get();
+ String newLabel = Context.getLanguageBinding("update.remote").get();
+ String header = Context.getLanguageBinding(STR."update.upgrade.\{upgrade ? "new" : "not"}").get();
+
+ // 版本检查消息
+ String msg = STR."\{app.getRepo()}\{upgrade ? "" : STR." \{version}"} \{header} \{upgrade ? newVersion : ""}";
+ log.info(msg);
+ ConsoleLog.info(msg);
+
+ // 弹窗
+ AlertBuilder builder = upgrade ? AlertUtil.confirm() : AlertUtil.info();
+ builder.title(title)
+ .header(header)
+ .content(STR."""
+ \{currentLabel} : \{version}
+ \{newLabel} : \{newVersion}
+ """)
+ .show(() -> {
+ // 可升级,且点击了确定后,开始下载任务
+ if (upgrade)
+ DownloadUtil.startDownload(app, newVersion, () -> {
+
+ // 下载完成后,解压并删除文件
+ DownloadUtil.unzip(app);
+
+ // 解压后
+ Platform.runLater(() -> {
+ switch (app) {
+ case AList _ -> {
+ // 设置应用版本
+ 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");
+ }
+ default -> throw new IllegalStateException(STR."Unexpected value: \{app}");
+ }
+ });
+
+ }).execute();
+ });
+ }
}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index a63aa58..cc5a405 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,3 +1,3 @@
app.name=${project.name}
app.title=AList GUI
-app.version=${project.version}
\ No newline at end of file
+app.version=v${project.version}
\ No newline at end of file