mirror of
https://github.com/octopusYan/alist-gui.git
synced 2025-12-08 09:11:56 +08:00
Compare commits
10 Commits
alpha/v1.0
...
ef7f4461c2
| Author | SHA1 | Date | |
|---|---|---|---|
| ef7f4461c2 | |||
| 6670dc7210 | |||
| 98c4ec2cd8 | |||
| 7e0ec8b598 | |||
| 47b001cdf8 | |||
| b9e842a80c | |||
| 899f286682 | |||
| 229662bd15 | |||
| 6294fdbf42 | |||
| fbdf6b3ba7 |
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -118,7 +118,7 @@ jobs:
|
||||
- name: Build with Maven
|
||||
run: |
|
||||
mvn clean package -f pom.xml
|
||||
mkdir zipball && cp target/*-windows.zip zipball
|
||||
mkdir zipball && cp target/*.zip zipball
|
||||
|
||||
- name: Upload AListGUI to Github
|
||||
uses: actions/upload-artifact@v4
|
||||
|
||||
34
README.md
34
README.md
@ -18,6 +18,40 @@
|
||||
|
||||
### TODO
|
||||
|
||||
### 截图
|
||||
|
||||
<details>
|
||||
<summary> 主界面 </summary>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/909ac6ad-0021-47d7-a75c-7fb6505e8c15">
|
||||
<img alt="main" src="https://github.com/user-attachments/assets/4984f7fb-acaa-4dbc-a322-8b6b89557cbf">
|
||||
</picture>
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary> 管理员信息 </summary>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/840dca69-e67d-4083-88f8-8e67c3e47141">
|
||||
<img alt="main" src="https://github.com/user-attachments/assets/a93d5967-65b5-4185-8bfb-77e55d811532">
|
||||
</picture>
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary> 设置 </summary>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/8fc8c489-b9cd-4e34-ad32-4899ccc275e9">
|
||||
<img alt="main" src="https://github.com/user-attachments/assets/f4cc78df-0718-4bac-9985-3761611f8f57">
|
||||
</picture>
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary> 关于 </summary>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/dbef2d66-4ca4-4e89-8292-dbdce3566f93">
|
||||
<img alt="about" src="https://github.com/user-attachments/assets/0e474a5d-78f3-4475-a8a9-fca15c3ed515">
|
||||
</picture>
|
||||
</details>
|
||||
|
||||
#### 本地运行
|
||||
|
||||
1. 克隆代码
|
||||
|
||||
23
pom.xml
23
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>cn.octopusyan</groupId>
|
||||
<artifactId>alist-gui</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.1</version>
|
||||
<name>alist-gui</name>
|
||||
|
||||
<organization>
|
||||
@ -258,18 +258,18 @@
|
||||
<vmArgs>
|
||||
<arg>--enable-preview</arg>
|
||||
<arg>-Xmx100m</arg>
|
||||
<!-- <arg>-Djava.awt.headless=false</arg>-->
|
||||
</vmArgs>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>bundling-for-windows</id>
|
||||
<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>
|
||||
@ -277,6 +277,23 @@
|
||||
</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>
|
||||
|
||||
@ -4,7 +4,7 @@ import cn.octopusyan.alistgui.Application;
|
||||
import cn.octopusyan.alistgui.config.Context;
|
||||
import cn.octopusyan.alistgui.config.I18n;
|
||||
import cn.octopusyan.alistgui.util.FxmlUtil;
|
||||
import cn.octopusyan.alistgui.util.WindowsUtil;
|
||||
import cn.octopusyan.alistgui.util.ViewUtil;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Labeled;
|
||||
@ -83,7 +83,7 @@ public abstract class BaseController<VM extends BaseViewModel> implements Initia
|
||||
// 全局窗口拖拽
|
||||
if (dragWindow() && getRootPanel() != null) {
|
||||
// 窗口拖拽
|
||||
WindowsUtil.bindDragged(getRootPanel());
|
||||
ViewUtil.bindDragged(getRootPanel());
|
||||
}
|
||||
|
||||
// 国际化绑定
|
||||
|
||||
@ -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<AboutViewModule> {
|
||||
}
|
||||
|
||||
public void checkGuiUpdate() {
|
||||
// TODO 检查 gui 版本
|
||||
AlertUtil.info("待开发。。。").show();
|
||||
viewModel.checkUpdate(ConfigManager.gui());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ 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.WindowsUtil;
|
||||
import cn.octopusyan.alistgui.util.ViewUtil;
|
||||
import cn.octopusyan.alistgui.viewModel.RootViewModel;
|
||||
import com.gluonhq.emoji.EmojiData;
|
||||
import com.gluonhq.emoji.util.EmojiImageUtils;
|
||||
@ -129,7 +129,7 @@ public class RootController extends BaseController<RootViewModel> {
|
||||
getWindow().setAlwaysOnTop(newVal);
|
||||
});
|
||||
|
||||
WindowsUtil.bindDragged(windowHeader);
|
||||
ViewUtil.bindDragged(windowHeader);
|
||||
|
||||
viewModel.currentViewIndexProperty().bind(tabPane.getSelectionModel().selectedIndexProperty());
|
||||
}
|
||||
@ -143,6 +143,11 @@ public class RootController extends BaseController<RootViewModel> {
|
||||
Context.openUrl("https://github.com/alist-org/alist");
|
||||
}
|
||||
|
||||
public void showTab(int index) {
|
||||
if (index < 0 || index > 2) return;
|
||||
tabPane.getSelectionModel().select(index);
|
||||
}
|
||||
|
||||
public void showModal(Node node, boolean persistent) {
|
||||
modalPane.show(node);
|
||||
modalPane.setPersistent(persistent);
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -3,7 +3,7 @@ package cn.octopusyan.alistgui.manager;
|
||||
import cn.octopusyan.alistgui.Application;
|
||||
import cn.octopusyan.alistgui.config.Constants;
|
||||
import cn.octopusyan.alistgui.config.Context;
|
||||
import cn.octopusyan.alistgui.util.WindowsUtil;
|
||||
import cn.octopusyan.alistgui.util.ViewUtil;
|
||||
import cn.octopusyan.alistgui.view.PopupMenu;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.binding.StringBinding;
|
||||
@ -48,7 +48,7 @@ public class SystemTrayManager {
|
||||
|
||||
public static void icon(String path) {
|
||||
if (trayIcon == null) return;
|
||||
icon(WindowsUtil.class.getResource(path));
|
||||
icon(ViewUtil.class.getResource(path));
|
||||
}
|
||||
|
||||
public static void icon(URL url) {
|
||||
@ -100,7 +100,7 @@ public class SystemTrayManager {
|
||||
if (trayIcon != null) return;
|
||||
|
||||
// 系统托盘图标
|
||||
URL resource = WindowsUtil.class.getResource(STR."/assets/logo\{running ? "" : "-disabled"}.png");
|
||||
URL resource = ViewUtil.class.getResource(STR."/assets/logo\{running ? "" : "-disabled"}.png");
|
||||
Image image = Toolkit.getDefaultToolkit().getImage(resource);
|
||||
trayIcon = new TrayIcon(image);
|
||||
|
||||
@ -187,6 +187,6 @@ public class SystemTrayManager {
|
||||
}
|
||||
|
||||
private static Stage stage() {
|
||||
return WindowsUtil.getStage();
|
||||
return ViewUtil.getStage();
|
||||
}
|
||||
}
|
||||
@ -18,7 +18,7 @@ public class GuiConfig {
|
||||
|
||||
private Boolean autoStart = false;
|
||||
private Boolean silentStartup = false;
|
||||
private Boolean closeToTray = true;
|
||||
private Boolean closeToTray = false;
|
||||
@JsonProperty("proxy")
|
||||
private ProxyInfo proxyInfo;
|
||||
@JsonProperty("proxy.testUrl")
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -5,8 +5,11 @@ import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import cn.octopusyan.alistgui.config.Constants;
|
||||
import cn.octopusyan.alistgui.config.Context;
|
||||
import cn.octopusyan.alistgui.controller.RootController;
|
||||
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 +27,6 @@ import java.util.zip.ZipFile;
|
||||
@Slf4j
|
||||
public class DownloadUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*
|
||||
@ -32,12 +34,19 @@ 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
|
||||
public void onRunning() {
|
||||
// 不展示进度条
|
||||
RootController root = (RootController) Context.getControllers().get(RootController.class.getSimpleName());
|
||||
root.showTab(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,6 +73,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()) {
|
||||
// 目录
|
||||
|
||||
@ -13,7 +13,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author octopus_yan
|
||||
*/
|
||||
public class WindowsUtil {
|
||||
public class ViewUtil {
|
||||
// 获取系统缩放比
|
||||
public static final double scaleX = Screen.getPrimary().getOutputScaleX();
|
||||
public static final double scaleY = Screen.getPrimary().getOutputScaleY();
|
||||
@ -2,7 +2,7 @@ package cn.octopusyan.alistgui.view;
|
||||
|
||||
import atlantafx.base.controls.CaptionMenuItem;
|
||||
import cn.octopusyan.alistgui.config.Constants;
|
||||
import cn.octopusyan.alistgui.util.WindowsUtil;
|
||||
import cn.octopusyan.alistgui.util.ViewUtil;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.binding.StringBinding;
|
||||
import javafx.event.ActionEvent;
|
||||
@ -115,8 +115,8 @@ public class PopupMenu {
|
||||
root.hide();
|
||||
|
||||
root.show(utilityStage,
|
||||
event.getX() / WindowsUtil.scaleX,
|
||||
event.getY() / WindowsUtil.scaleY
|
||||
event.getX() / ViewUtil.scaleX,
|
||||
event.getY() / ViewUtil.scaleY
|
||||
);
|
||||
// 获取焦点 (失去焦点隐藏自身)
|
||||
root.requestFocus();
|
||||
|
||||
@ -2,7 +2,7 @@ package cn.octopusyan.alistgui.view.alert.builder;
|
||||
|
||||
import cn.octopusyan.alistgui.base.BaseBuilder;
|
||||
import cn.octopusyan.alistgui.config.Context;
|
||||
import cn.octopusyan.alistgui.util.WindowsUtil;
|
||||
import cn.octopusyan.alistgui.util.ViewUtil;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.ButtonBar;
|
||||
import javafx.scene.control.ButtonType;
|
||||
@ -26,9 +26,9 @@ public class DefaultBuilder extends BaseBuilder<DefaultBuilder, Dialog<?>> {
|
||||
|
||||
DialogPane dialogPane = dialog.getDialogPane();
|
||||
dialogPane.getScene().setFill(Color.TRANSPARENT);
|
||||
WindowsUtil.bindDragged(dialogPane);
|
||||
WindowsUtil.bindShadow(dialogPane);
|
||||
WindowsUtil.getStage(dialogPane).initStyle(StageStyle.TRANSPARENT);
|
||||
ViewUtil.bindDragged(dialogPane);
|
||||
ViewUtil.bindShadow(dialogPane);
|
||||
ViewUtil.getStage(dialogPane).initStyle(StageStyle.TRANSPARENT);
|
||||
|
||||
dialogPane.getButtonTypes().add(new ButtonType(
|
||||
Context.getLanguageBinding("label.cancel").get(),
|
||||
|
||||
@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
app.name=${project.name}
|
||||
app.title=AList GUI
|
||||
app.version=${project.version}
|
||||
app.version=v${project.version}
|
||||
Reference in New Issue
Block a user