mirror of
https://github.com/octopusYan/alist-gui.git
synced 2024-11-23 20:46:42 +08:00
Compare commits
No commits in common. "47b001cdf8211e0fcfa5bf7c5bf5389b7120f83c" and "ec585ea29d54cd2849296f023580131c7799ad33" have entirely different histories.
47b001cdf8
...
ec585ea29d
5
.github/workflows/auto-alpha-tag.yml
vendored
5
.github/workflows/auto-alpha-tag.yml
vendored
@ -4,11 +4,6 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- "dev"
|
||||
paths:
|
||||
- ".github/workflows/*.yml"
|
||||
- "src/**"
|
||||
- "pom.xml"
|
||||
- "!**/*.md"
|
||||
pull_request:
|
||||
branches:
|
||||
- "dev"
|
||||
|
34
README.md
34
README.md
@ -18,40 +18,6 @@
|
||||
|
||||
### 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. 克隆代码
|
||||
|
19
pom.xml
19
pom.xml
@ -258,6 +258,7 @@
|
||||
<vmArgs>
|
||||
<arg>--enable-preview</arg>
|
||||
<arg>-Xmx100m</arg>
|
||||
<!-- <arg>-Djava.awt.headless=false</arg>-->
|
||||
</vmArgs>
|
||||
</configuration>
|
||||
<executions>
|
||||
@ -269,7 +270,6 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<platform>windows</platform>
|
||||
<zipballName>${project.name}-windows</zipballName>
|
||||
<createZipball>true</createZipball>
|
||||
<winConfig>
|
||||
<headerType>gui</headerType>
|
||||
@ -277,23 +277,6 @@
|
||||
</winConfig>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>bundling-for-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>
|
||||
|
@ -2,28 +2,19 @@ package cn.octopusyan.alistgui.base;
|
||||
|
||||
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.ViewUtil;
|
||||
import cn.octopusyan.alistgui.util.WindowsUtil;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Labeled;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Stage;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
@ -52,29 +43,6 @@ public abstract class BaseController<VM extends BaseViewModel> implements Initia
|
||||
}
|
||||
}
|
||||
viewModel = vm;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 国际化绑定
|
||||
*/
|
||||
private void bindI18n() {
|
||||
// i18n 绑定
|
||||
try {
|
||||
for (Field field : getAllField(this.getClass())) {
|
||||
I18n i18n = field.getAnnotation(I18n.class);
|
||||
if (i18n != null && StringUtils.isNoneEmpty(i18n.key())) {
|
||||
switch (field.get(this)) {
|
||||
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 -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
logger.error("获取属性失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
@ -83,12 +51,9 @@ public abstract class BaseController<VM extends BaseViewModel> implements Initia
|
||||
// 全局窗口拖拽
|
||||
if (dragWindow() && getRootPanel() != null) {
|
||||
// 窗口拖拽
|
||||
ViewUtil.bindDragged(getRootPanel());
|
||||
WindowsUtil.bindDragged(getRootPanel());
|
||||
}
|
||||
|
||||
// 国际化绑定
|
||||
bindI18n();
|
||||
|
||||
// 初始化数据
|
||||
initData();
|
||||
|
||||
@ -144,16 +109,4 @@ public abstract class BaseController<VM extends BaseViewModel> implements Initia
|
||||
* 视图事件
|
||||
*/
|
||||
public abstract void initViewAction();
|
||||
|
||||
|
||||
private static List<Field> getAllField(Class<?> class1) {
|
||||
List<Field> list = new ArrayList<>();
|
||||
while (class1 != Object.class) {
|
||||
list.addAll(Arrays.stream(class1.getDeclaredFields()).toList());
|
||||
//获取父类
|
||||
class1 = class1.getSuperclass();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,17 @@
|
||||
package cn.octopusyan.alistgui.config;
|
||||
|
||||
import atlantafx.base.theme.Theme;
|
||||
import cn.octopusyan.alistgui.Application;
|
||||
import cn.octopusyan.alistgui.base.BaseController;
|
||||
import cn.octopusyan.alistgui.controller.*;
|
||||
import cn.octopusyan.alistgui.controller.AboutController;
|
||||
import cn.octopusyan.alistgui.controller.MainController;
|
||||
import cn.octopusyan.alistgui.controller.RootController;
|
||||
import cn.octopusyan.alistgui.controller.SetupController;
|
||||
import cn.octopusyan.alistgui.manager.ConfigManager;
|
||||
import cn.octopusyan.alistgui.manager.ConsoleLog;
|
||||
import cn.octopusyan.alistgui.util.FxmlUtil;
|
||||
import cn.octopusyan.alistgui.util.ProcessesUtil;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.binding.StringBinding;
|
||||
import javafx.beans.property.IntegerProperty;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
@ -36,6 +41,7 @@ public class Context {
|
||||
private static final Logger log = LoggerFactory.getLogger(Context.class);
|
||||
private static Scene scene;
|
||||
private static final IntegerProperty currentViewIndex = new SimpleIntegerProperty(0);
|
||||
private static final ObjectProperty<Theme> theme = new SimpleObjectProperty<>(ConfigManager.theme());
|
||||
|
||||
/**
|
||||
* 控制器集合
|
||||
@ -73,7 +79,6 @@ public class Context {
|
||||
case MainController main -> main;
|
||||
case SetupController setup -> setup;
|
||||
case AboutController about -> about;
|
||||
case PasswordController passwod -> passwod;
|
||||
default -> throw new IllegalStateException(STR."Unexpected value: \{type}");
|
||||
};
|
||||
} catch (Exception e) {
|
||||
@ -87,6 +92,10 @@ public class Context {
|
||||
Context.application = application;
|
||||
}
|
||||
|
||||
public static ObjectProperty<Theme> themeProperty() {
|
||||
return theme;
|
||||
}
|
||||
|
||||
// 获取当前所选时区属性
|
||||
public static ObjectProperty<Locale> currentLocaleProperty() {
|
||||
return currentLocale;
|
||||
@ -141,6 +150,12 @@ public class Context {
|
||||
return LANGUAGE_RESOURCE_FACTORY.getResourceBundleProperty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化 语言
|
||||
*/
|
||||
private static void initI18n() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 有此类所在路径决定相对路径
|
||||
*
|
||||
@ -158,8 +173,17 @@ public class Context {
|
||||
* @return Scene
|
||||
*/
|
||||
public static Scene initScene() {
|
||||
// locale监听; 切换后,重新加载界面
|
||||
currentLocaleProperty().addListener((_, _, locale) -> Platform.runLater(Context::loadScene));
|
||||
// 加载
|
||||
loadScene();
|
||||
return scene;
|
||||
}
|
||||
|
||||
private static void loadScene() {
|
||||
try {
|
||||
FXMLLoader loader = FxmlUtil.load("root-view");
|
||||
loader.setControllerFactory(Context.getControlFactory());
|
||||
//底层面板
|
||||
Pane root = loader.load();
|
||||
Optional.ofNullable(scene).ifPresentOrElse(
|
||||
@ -174,7 +198,6 @@ public class Context {
|
||||
} catch (Throwable e) {
|
||||
log.error("loadScene error", e);
|
||||
}
|
||||
return scene;
|
||||
}
|
||||
|
||||
public static int currentViewIndex() {
|
||||
|
@ -1,15 +0,0 @@
|
||||
package cn.octopusyan.alistgui.config;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 显示文本绑定
|
||||
*
|
||||
* @author octopus_yan
|
||||
*/
|
||||
@Documented
|
||||
@Target({ElementType.FIELD})//用此注解用在属性上。
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface I18n {
|
||||
String key() default "";
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package cn.octopusyan.alistgui.config;
|
||||
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.binding.StringBinding;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
@ -27,6 +26,15 @@ public class ObservableResourceBundleFactory {
|
||||
}
|
||||
|
||||
public StringBinding getStringBinding(String key) {
|
||||
return Bindings.createStringBinding(() -> getResourceBundle().getString(key), resourceBundleProperty);
|
||||
return new StringBinding() {
|
||||
{
|
||||
bind(resourceBundleProperty);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String computeValue() {
|
||||
return getResourceBundle().getString(key);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
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.fxml.FXML;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.VBox;
|
||||
import org.slf4j.Logger;
|
||||
@ -18,22 +18,12 @@ import org.slf4j.LoggerFactory;
|
||||
public class AboutController extends BaseController<AboutViewModule> {
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@FXML
|
||||
public VBox aboutView;
|
||||
|
||||
@FXML
|
||||
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
|
||||
public VBox getRootPanel() {
|
||||
return aboutView;
|
||||
@ -54,12 +44,15 @@ public class AboutController extends BaseController<AboutViewModule> {
|
||||
aListVersion.textProperty().bindBidirectional(viewModel.aListVersionProperty());
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void checkAListUpdate() {
|
||||
viewModel.checkUpdate(ConfigManager.aList());
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void checkGuiUpdate() {
|
||||
viewModel.checkUpdate(ConfigManager.gui());
|
||||
// TODO 检查 gui 版本
|
||||
AlertUtil.info("待开发。。。").show();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,16 +2,13 @@ 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;
|
||||
import cn.octopusyan.alistgui.viewModel.MainViewModel;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.binding.StringBinding;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.MenuButton;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
@ -28,34 +25,19 @@ import java.io.IOException;
|
||||
public class MainController extends BaseController<MainViewModel> {
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@FXML
|
||||
public VBox mainView;
|
||||
@FXML
|
||||
public VBox logArea;
|
||||
@FXML
|
||||
public ScrollPane logAreaSp;
|
||||
|
||||
@I18n(key = "main.status.label-stop")
|
||||
@FXML
|
||||
public Button statusLabel;
|
||||
|
||||
@I18n(key = "main.control.start")
|
||||
@FXML
|
||||
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")
|
||||
@FXML
|
||||
public MenuItem browserButton;
|
||||
|
||||
@I18n(key = "main.more.open-config")
|
||||
public MenuItem configButton;
|
||||
|
||||
@I18n(key = "main.more.open-log")
|
||||
public MenuItem logButton;
|
||||
|
||||
private PasswordController controller;
|
||||
|
||||
@Override
|
||||
@ -70,18 +52,19 @@ public class MainController extends BaseController<MainViewModel> {
|
||||
|
||||
@Override
|
||||
public void initViewStyle() {
|
||||
// 运行状态监听
|
||||
viewModel.runningProperty().addListener((_, _, running) -> {
|
||||
resetStatus(running);
|
||||
browserButton.disableProperty().set(!running);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initViewAction() {
|
||||
viewModel.startBtnStyleCssProperty().bindContentBidirectional(startButton.getStyleClass());
|
||||
viewModel.statusLabelStyleCssProperty().bindContentBidirectional(statusLabel.getStyleClass());
|
||||
viewModel.startBtnTextProperty().bindBidirectional(startButton.textProperty());
|
||||
viewModel.statusLabelTextProperty().bindBidirectional(statusLabel.textProperty());
|
||||
viewModel.browserButtonDisableProperty().bindBidirectional(browserButton.disableProperty());
|
||||
}
|
||||
|
||||
// start button
|
||||
@FXML
|
||||
public void start() {
|
||||
if (AListManager.isRunning()) {
|
||||
AListManager.stop();
|
||||
@ -91,6 +74,7 @@ public class MainController extends BaseController<MainViewModel> {
|
||||
}
|
||||
|
||||
// password button
|
||||
@FXML
|
||||
public void adminPassword() throws IOException {
|
||||
if (controller == null) {
|
||||
FXMLLoader load = FxmlUtil.load("admin-panel");
|
||||
@ -101,43 +85,29 @@ public class MainController extends BaseController<MainViewModel> {
|
||||
}
|
||||
|
||||
// restart button
|
||||
@FXML
|
||||
public void restart() {
|
||||
AListManager.restart();
|
||||
}
|
||||
|
||||
// more button
|
||||
|
||||
@FXML
|
||||
public void openInBrowser() {
|
||||
AListManager.openScheme();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void openLogFolder() {
|
||||
AListManager.openLogFolder();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void openConfig() {
|
||||
AListManager.openConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据运行状态改变按钮样式
|
||||
*
|
||||
* @param running 运行状态
|
||||
*/
|
||||
private void resetStatus(boolean running) {
|
||||
String removeStyle = running ? "success" : "danger";
|
||||
String addStyle = running ? "danger" : "success";
|
||||
StringBinding button = Context.getLanguageBinding(STR."main.control.\{running ? "stop" : "start"}");
|
||||
StringBinding status = Context.getLanguageBinding(STR."main.status.label-\{running ? "running" : "stop"}");
|
||||
|
||||
Platform.runLater(() -> {
|
||||
startButton.getStyleClass().remove(removeStyle);
|
||||
startButton.getStyleClass().add(addStyle);
|
||||
startButton.textProperty().bind(button);
|
||||
|
||||
statusLabel.getStyleClass().remove(addStyle);
|
||||
statusLabel.getStyleClass().add(removeStyle);
|
||||
statusLabel.textProperty().bind(status);
|
||||
});
|
||||
private String getText(String key) {
|
||||
return Context.getLanguageBinding(key).get();
|
||||
}
|
||||
}
|
||||
|
@ -4,14 +4,12 @@ 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;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.PasswordField;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
@ -25,20 +23,20 @@ import org.apache.commons.lang3.StringUtils;
|
||||
* @author octopus_yan
|
||||
*/
|
||||
public class PasswordController extends BaseController<AdminPanelViewModel> {
|
||||
public AnchorPane adminPanel;
|
||||
@FXML
|
||||
private AnchorPane adminPanel;
|
||||
|
||||
@I18n(key = "admin.pwd.toptip")
|
||||
public Label toptip;
|
||||
@I18n(key = "admin.pwd.user-field")
|
||||
public Label usernameLabel;
|
||||
@FXML
|
||||
public TextField usernameField;
|
||||
@FXML
|
||||
public Button copyUsername;
|
||||
@I18n(key = "admin.pwd.pwd-field")
|
||||
public Label passwordLabel;
|
||||
@FXML
|
||||
public PasswordField passwordField;
|
||||
@FXML
|
||||
public Button refreshPassword;
|
||||
@FXML
|
||||
public Button savePassword;
|
||||
@FXML
|
||||
public Button copyPassword;
|
||||
|
||||
private RootController root;
|
||||
|
@ -3,19 +3,18 @@ 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;
|
||||
import cn.octopusyan.alistgui.util.WindowsUtil;
|
||||
import cn.octopusyan.alistgui.viewModel.RootViewModel;
|
||||
import com.gluonhq.emoji.EmojiData;
|
||||
import com.gluonhq.emoji.util.EmojiImageUtils;
|
||||
import javafx.application.Platform;
|
||||
import javafx.css.PseudoClass;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TabPane;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
@ -32,28 +31,27 @@ import java.util.Locale;
|
||||
*/
|
||||
public class RootController extends BaseController<RootViewModel> {
|
||||
// 布局
|
||||
public StackPane rootPane;
|
||||
public HBox windowHeader;
|
||||
public FontIcon alwaysOnTopIcon;
|
||||
public FontIcon minimizeIcon;
|
||||
public FontIcon closeIcon;
|
||||
@FXML
|
||||
private StackPane rootPane;
|
||||
@FXML
|
||||
private HBox windowHeader;
|
||||
@FXML
|
||||
private FontIcon alwaysOnTopIcon;
|
||||
@FXML
|
||||
private FontIcon minimizeIcon;
|
||||
@FXML
|
||||
private FontIcon closeIcon;
|
||||
|
||||
// 界面
|
||||
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;
|
||||
@FXML
|
||||
private TabPane tabPane;
|
||||
|
||||
// footer
|
||||
@I18n(key = "root.foot.doc")
|
||||
@FXML
|
||||
public Button document;
|
||||
@I18n(key = "root.foot.github")
|
||||
@FXML
|
||||
public Button github;
|
||||
@I18n(key = "root.foot.sponsor")
|
||||
@FXML
|
||||
public Button sponsor;
|
||||
|
||||
private final ModalPane modalPane = new ModalPane();
|
||||
@ -96,7 +94,6 @@ public class RootController extends BaseController<RootViewModel> {
|
||||
sponsor.setGraphic(juice);
|
||||
});
|
||||
|
||||
// 遮罩
|
||||
getRootPanel().getChildren().add(modalPane);
|
||||
modalPane.setId("modalPane");
|
||||
// reset side and transition to reuse a single modal pane between different examples
|
||||
@ -129,25 +126,22 @@ public class RootController extends BaseController<RootViewModel> {
|
||||
getWindow().setAlwaysOnTop(newVal);
|
||||
});
|
||||
|
||||
ViewUtil.bindDragged(windowHeader);
|
||||
WindowsUtil.bindDragged(windowHeader);
|
||||
|
||||
viewModel.currentViewIndexProperty().bind(tabPane.getSelectionModel().selectedIndexProperty());
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void openDocument() {
|
||||
String locale = Context.getCurrentLocale().equals(Locale.ENGLISH) ? "" : "zh/";
|
||||
Context.openUrl(STR."https://alist.nn.ci/\{locale}");
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void openGithub() {
|
||||
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);
|
||||
|
@ -3,15 +3,16 @@ 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;
|
||||
import cn.octopusyan.alistgui.viewModel.SetupViewModel;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.util.StringConverter;
|
||||
@ -31,24 +32,26 @@ public class SetupController extends BaseController<SetupViewModel> implements I
|
||||
|
||||
@FXML
|
||||
public VBox setupView;
|
||||
@I18n(key = "setup.auto-start.label")
|
||||
@FXML
|
||||
public CheckBox autoStartCheckBox;
|
||||
@I18n(key = "setup.silent-startup.label")
|
||||
@FXML
|
||||
public CheckBox silentStartupCheckBox;
|
||||
@I18n(key = "setup.close-to-tray.label")
|
||||
@FXML
|
||||
public CheckBox closeToTrayCheckBox;
|
||||
@FXML
|
||||
public ComboBox<Locale> languageComboBox;
|
||||
@FXML
|
||||
public ComboBox<Theme> themeComboBox;
|
||||
@FXML
|
||||
public ComboBox<ProxySetup> proxySetupComboBox;
|
||||
@FXML
|
||||
public Pane proxySetupPane;
|
||||
@I18n(key = "setup.proxy.test")
|
||||
@FXML
|
||||
public Button proxyCheck;
|
||||
@FXML
|
||||
public TextField proxyHost;
|
||||
@FXML
|
||||
public TextField proxyPort;
|
||||
@I18n(key = "setup.proxy.host")
|
||||
public Label hostLabel;
|
||||
@I18n(key = "setup.proxy.port")
|
||||
public Label portLabel;
|
||||
|
||||
@Override
|
||||
public VBox getRootPanel() {
|
||||
@ -61,9 +64,6 @@ public class SetupController extends BaseController<SetupViewModel> implements I
|
||||
themeComboBox.setItems(FXCollections.observableList(ConfigManager.THEME_LIST));
|
||||
proxySetupComboBox.setItems(FXCollections.observableList(List.of(ProxySetup.values())));
|
||||
|
||||
proxySetupComboBox.setCellFactory(_ -> new ProxySetupCell());
|
||||
proxySetupComboBox.setButtonCell(new ProxySetupCell());
|
||||
|
||||
themeComboBox.setConverter(new StringConverter<>() {
|
||||
@Override
|
||||
public String toString(Theme object) {
|
||||
@ -82,14 +82,6 @@ public class SetupController extends BaseController<SetupViewModel> implements I
|
||||
proxySetupComboBox.getSelectionModel().selectedItemProperty().addListener((_, _, newValue) -> {
|
||||
proxySetupPane.setVisible(ProxySetup.MANUAL.equals(newValue));
|
||||
proxyCheck.setVisible(!ProxySetup.NO_PROXY.equals(newValue));
|
||||
|
||||
// proxySetupComboBox.promptTextProperty().bind(
|
||||
//// Bindings.createStringBinding(
|
||||
//// () -> Context.getLanguageBinding(STR."proxy.setup.label.\{newValue.getName()}").get(),
|
||||
//// Context.currentLocaleProperty()
|
||||
//// )
|
||||
// Context.getLanguageBinding(STR."proxy.setup.label.\{newValue.getName()}")
|
||||
// );
|
||||
});
|
||||
|
||||
languageComboBox.getSelectionModel().select(ConfigManager.language());
|
||||
@ -111,6 +103,7 @@ public class SetupController extends BaseController<SetupViewModel> implements I
|
||||
viewModel.proxySetupProperty().bind(proxySetupComboBox.getSelectionModel().selectedItemProperty());
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void proxyTest() {
|
||||
viewModel.proxyTest();
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package cn.octopusyan.alistgui.enums;
|
||||
|
||||
import cn.octopusyan.alistgui.config.Context;
|
||||
import javafx.beans.binding.StringBinding;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@ -21,10 +20,6 @@ public enum ProxySetup {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getBinding().get();
|
||||
}
|
||||
|
||||
public StringBinding getBinding() {
|
||||
return Context.getLanguageBinding(STR."proxy.setup.label.\{getName()}");
|
||||
return Context.getLanguageBinding("proxy.setup.label." + getName()).getValue();
|
||||
}
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ public class AListManager {
|
||||
}
|
||||
|
||||
var task = new CheckUpdateTask(ConfigManager.aList());
|
||||
task.onListen(new TaskListener.UpgradeListener(task) {
|
||||
task.onListen(new TaskListener.UpgradeUpgradeListener(task) {
|
||||
@Override
|
||||
public void onChecked(boolean hasUpgrade, String version) {
|
||||
Platform.runLater(() -> showDownload(version));
|
||||
|
@ -3,10 +3,9 @@ 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.ViewUtil;
|
||||
import cn.octopusyan.alistgui.util.WindowsUtil;
|
||||
import cn.octopusyan.alistgui.view.PopupMenu;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.binding.StringBinding;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.stage.Stage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -48,7 +47,7 @@ public class SystemTrayManager {
|
||||
|
||||
public static void icon(String path) {
|
||||
if (trayIcon == null) return;
|
||||
icon(ViewUtil.class.getResource(path));
|
||||
icon(WindowsUtil.class.getResource(path));
|
||||
}
|
||||
|
||||
public static void icon(URL url) {
|
||||
@ -77,7 +76,7 @@ public class SystemTrayManager {
|
||||
return;
|
||||
}
|
||||
|
||||
initTrayIcon(AListManager.isRunning());
|
||||
initTrayIcon();
|
||||
|
||||
try {
|
||||
if (!isShowing())
|
||||
@ -96,12 +95,11 @@ public class SystemTrayManager {
|
||||
|
||||
//========================================={ private }===========================================
|
||||
|
||||
private static void initTrayIcon(boolean running) {
|
||||
private static void initTrayIcon() {
|
||||
if (trayIcon != null) return;
|
||||
|
||||
// 系统托盘图标
|
||||
URL resource = ViewUtil.class.getResource(STR."/assets/logo\{running ? "" : "-disabled"}.png");
|
||||
Image image = Toolkit.getDefaultToolkit().getImage(resource);
|
||||
Image image = Toolkit.getDefaultToolkit().getImage(WindowsUtil.class.getResource("/assets/logo-disabled.png"));
|
||||
trayIcon = new TrayIcon(image);
|
||||
|
||||
// 设置图标尺寸自动适应
|
||||
@ -131,7 +129,7 @@ public class SystemTrayManager {
|
||||
if (event.isPopupTrigger()) {
|
||||
// 弹出菜单
|
||||
Platform.runLater(() -> {
|
||||
initPopupMenu(running);
|
||||
initPopupMenu();
|
||||
popupMenu.show(event);
|
||||
});
|
||||
} else if (event.getButton() == MouseEvent.BUTTON1) {
|
||||
@ -145,19 +143,15 @@ public class SystemTrayManager {
|
||||
/**
|
||||
* 构建托盘菜单
|
||||
*/
|
||||
private static void initPopupMenu(boolean running) {
|
||||
private static void initPopupMenu() {
|
||||
if (popupMenu != null) return;
|
||||
|
||||
MenuItem start = PopupMenu.menuItem(
|
||||
getStringBinding(STR."main.control.\{running ? "stop" : "start"}"),
|
||||
_ -> AListManager.openScheme()
|
||||
);
|
||||
MenuItem browser = PopupMenu.menuItem(getStringBinding("main.more.browser"), _ -> AListManager.openScheme());
|
||||
browser.setDisable(!running);
|
||||
MenuItem start = PopupMenu.menuItem(getString("main.control.start"), _ -> AListManager.openScheme());
|
||||
MenuItem browser = PopupMenu.menuItem(getString("main.more.browser"), _ -> AListManager.openScheme());
|
||||
browser.setDisable(true);
|
||||
|
||||
AListManager.runningProperty().addListener((_, _, newValue) -> {
|
||||
start.textProperty().unbind();
|
||||
start.textProperty().bind(getStringBinding(STR."main.control.\{newValue ? "stop" : "start"}"));
|
||||
start.setText(getString(STR."main.control.\{newValue ? "stop" : "start"}"));
|
||||
browser.disableProperty().set(!newValue);
|
||||
toolTip(STR."AList \{newValue ? "running" : "stopped"}");
|
||||
icon(STR."/assets/logo\{newValue ? "" : "-disabled"}.png");
|
||||
@ -174,19 +168,19 @@ public class SystemTrayManager {
|
||||
AListManager.start();
|
||||
}
|
||||
})
|
||||
.addItem(getStringBinding("main.control.restart"), _ -> AListManager.restart())
|
||||
.addMenu(getStringBinding("main.control.more"), browser,
|
||||
PopupMenu.menuItem(getStringBinding("main.more.open-config"), _ -> AListManager.openConfig()),
|
||||
PopupMenu.menuItem(getStringBinding("main.more.open-log"), _ -> AListManager.openLogFolder()))
|
||||
.addItem(getString("main.control.restart"), _ -> AListManager.restart())
|
||||
.addMenu(getString("main.control.more"), browser,
|
||||
PopupMenu.menuItem(getString("main.more.open-config"), _ -> AListManager.openConfig()),
|
||||
PopupMenu.menuItem(getString("main.more.open-log"), _ -> AListManager.openLogFolder()))
|
||||
.addSeparator()
|
||||
.addExitItem();
|
||||
}
|
||||
|
||||
private static StringBinding getStringBinding(String key) {
|
||||
return Context.getLanguageBinding(key);
|
||||
private static String getString(String key) {
|
||||
return Context.getLanguageBinding(key).get();
|
||||
}
|
||||
|
||||
private static Stage stage() {
|
||||
return ViewUtil.getStage();
|
||||
return WindowsUtil.getStage();
|
||||
}
|
||||
}
|
@ -18,7 +18,7 @@ public class GuiConfig {
|
||||
|
||||
private Boolean autoStart = false;
|
||||
private Boolean silentStartup = false;
|
||||
private Boolean closeToTray = false;
|
||||
private Boolean closeToTray = true;
|
||||
@JsonProperty("proxy")
|
||||
private ProxyInfo proxyInfo;
|
||||
@JsonProperty("proxy.testUrl")
|
||||
|
@ -10,12 +10,18 @@ import lombok.Data;
|
||||
@Data
|
||||
public class Gui implements UpgradeApp {
|
||||
@JsonIgnore
|
||||
private final String owner = "octopusYan";
|
||||
|
||||
private final String owner = "alist-org";
|
||||
@JsonIgnore
|
||||
private final String repo = "alist-gui";
|
||||
|
||||
private String releaseFile = "alist-gui-windows-nojre.zip";
|
||||
private final String repo = "alist";
|
||||
|
||||
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,6 +1,7 @@
|
||||
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;
|
||||
|
||||
@ -12,12 +13,10 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Slf4j
|
||||
public class DownloadTask extends BaseTask {
|
||||
private final String downloadUrl;
|
||||
private final String savePath;
|
||||
|
||||
public DownloadTask(String downloadUrl, String savePath) {
|
||||
public DownloadTask(String downloadUrl) {
|
||||
super(STR."Download \{downloadUrl}");
|
||||
this.downloadUrl = downloadUrl;
|
||||
this.savePath = savePath;
|
||||
}
|
||||
|
||||
public void onListen(DownloadListener listener) {
|
||||
@ -28,7 +27,7 @@ public class DownloadTask extends BaseTask {
|
||||
protected void task() throws Exception {
|
||||
HttpUtil.getInstance().download(
|
||||
downloadUrl,
|
||||
savePath,
|
||||
Constants.BIN_DIR_PATH,
|
||||
listener instanceof DownloadListener ? ((DownloadListener) listener)::onProgress : null
|
||||
);
|
||||
}
|
||||
|
@ -89,8 +89,8 @@ public abstract class TaskListener implements BaseTask.Listener {
|
||||
/**
|
||||
* 检查更新监听默认实现
|
||||
*/
|
||||
public static abstract class UpgradeListener extends TaskListener implements CheckUpdateTask.UpgradeListener {
|
||||
public UpgradeListener(BaseTask task) {
|
||||
public static abstract class UpgradeUpgradeListener extends TaskListener implements CheckUpdateTask.UpgradeListener {
|
||||
public UpgradeUpgradeListener(BaseTask task) {
|
||||
super(task);
|
||||
}
|
||||
|
||||
|
@ -5,11 +5,8 @@ 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;
|
||||
@ -27,6 +24,7 @@ import java.util.zip.ZipFile;
|
||||
@Slf4j
|
||||
public class DownloadUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*
|
||||
@ -34,19 +32,12 @@ public class DownloadUtil {
|
||||
* @param version 下载版本
|
||||
*/
|
||||
public static DownloadTask startDownload(UpgradeApp app, String version, Runnable runnable) {
|
||||
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);
|
||||
var task = new DownloadTask(app.getDownloadUrl(version));
|
||||
task.onListen(new TaskListener.DownloadListener(task) {
|
||||
|
||||
@Override
|
||||
public void onRunning() {
|
||||
// 不展示进度条
|
||||
RootController root = (RootController) Context.getControllers().get(RootController.class.getSimpleName());
|
||||
root.showTab(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -73,11 +64,6 @@ 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()) {
|
||||
// 目录
|
||||
|
@ -25,7 +25,7 @@ public class FxmlUtil {
|
||||
FxmlUtil.class.getResource(prefix + name + suffix),
|
||||
bundle,
|
||||
new JavaFXBuilderFactory(),
|
||||
Context.getControlFactory(),
|
||||
null,
|
||||
StandardCharsets.UTF_8
|
||||
);
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ public class Registry {
|
||||
RESTORE,
|
||||
SAVE,
|
||||
UNLOAD,
|
||||
;
|
||||
}
|
||||
|
||||
public enum Root {
|
||||
@ -74,5 +75,6 @@ public class Registry {
|
||||
REG_LINK,
|
||||
REG_FULL_RESOURCE_DESCRIPTOR,
|
||||
REG_EXPAND_SZ,
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author octopus_yan
|
||||
*/
|
||||
public class ViewUtil {
|
||||
public class WindowsUtil {
|
||||
// 获取系统缩放比
|
||||
public static final double scaleX = Screen.getPrimary().getOutputScaleX();
|
||||
public static final double scaleY = Screen.getPrimary().getOutputScaleY();
|
@ -2,9 +2,8 @@ package cn.octopusyan.alistgui.view;
|
||||
|
||||
import atlantafx.base.controls.CaptionMenuItem;
|
||||
import cn.octopusyan.alistgui.config.Constants;
|
||||
import cn.octopusyan.alistgui.util.ViewUtil;
|
||||
import cn.octopusyan.alistgui.util.WindowsUtil;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.binding.StringBinding;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.Scene;
|
||||
@ -48,12 +47,6 @@ public class PopupMenu {
|
||||
return addItem(new MenuItem(label), handler);
|
||||
}
|
||||
|
||||
public PopupMenu addItem(StringBinding bind, EventHandler<ActionEvent> handler) {
|
||||
MenuItem menuItem = new MenuItem();
|
||||
menuItem.textProperty().bind(bind);
|
||||
return addItem(menuItem, handler);
|
||||
}
|
||||
|
||||
public PopupMenu addItem(MenuItem node, EventHandler<ActionEvent> handler) {
|
||||
node.setOnAction(handler);
|
||||
return addItem(node);
|
||||
@ -75,12 +68,6 @@ public class PopupMenu {
|
||||
return addMenu(new Menu(label), items);
|
||||
}
|
||||
|
||||
public PopupMenu addMenu(StringBinding label, MenuItem... items) {
|
||||
Menu menu = new Menu();
|
||||
menu.textProperty().bind(label);
|
||||
return addMenu(menu, items);
|
||||
}
|
||||
|
||||
public PopupMenu addMenu(Menu menu, MenuItem... items) {
|
||||
menu.getItems().addAll(items);
|
||||
return addItem(menu);
|
||||
@ -115,8 +102,8 @@ public class PopupMenu {
|
||||
root.hide();
|
||||
|
||||
root.show(utilityStage,
|
||||
event.getX() / ViewUtil.scaleX,
|
||||
event.getY() / ViewUtil.scaleY
|
||||
event.getX() / WindowsUtil.scaleX,
|
||||
event.getY() / WindowsUtil.scaleY
|
||||
);
|
||||
// 获取焦点 (失去焦点隐藏自身)
|
||||
root.requestFocus();
|
||||
@ -127,11 +114,4 @@ public class PopupMenu {
|
||||
menuItem.setOnAction(handler);
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
public static MenuItem menuItem(StringBinding stringBinding, EventHandler<ActionEvent> handler) {
|
||||
MenuItem menuItem = new MenuItem();
|
||||
menuItem.textProperty().bind(stringBinding);
|
||||
menuItem.setOnAction(handler);
|
||||
return menuItem;
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
package cn.octopusyan.alistgui.view;
|
||||
|
||||
import cn.octopusyan.alistgui.enums.ProxySetup;
|
||||
import javafx.scene.control.ListCell;
|
||||
|
||||
/**
|
||||
* ProxySetup I18n Cell
|
||||
*
|
||||
* @author octopus_yan
|
||||
*/
|
||||
public class ProxySetupCell extends ListCell<ProxySetup> {
|
||||
|
||||
@Override
|
||||
protected void updateItem(ProxySetup item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
textProperty().unbind();
|
||||
if (empty || item == null) {
|
||||
setText("");
|
||||
} else {
|
||||
textProperty().bind(item.getBinding());
|
||||
}
|
||||
}
|
||||
}
|
@ -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.ViewUtil;
|
||||
import cn.octopusyan.alistgui.util.WindowsUtil;
|
||||
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);
|
||||
ViewUtil.bindDragged(dialogPane);
|
||||
ViewUtil.bindShadow(dialogPane);
|
||||
ViewUtil.getStage(dialogPane).initStyle(StageStyle.TRANSPARENT);
|
||||
WindowsUtil.bindDragged(dialogPane);
|
||||
WindowsUtil.bindShadow(dialogPane);
|
||||
WindowsUtil.getStage(dialogPane).initStyle(StageStyle.TRANSPARENT);
|
||||
|
||||
dialogPane.getButtonTypes().add(new ButtonType(
|
||||
Context.getLanguageBinding("label.cancel").get(),
|
||||
|
@ -1,19 +1,14 @@
|
||||
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;
|
||||
@ -66,22 +61,52 @@ public class AboutViewModule extends BaseViewModel {
|
||||
* 检查更新
|
||||
*/
|
||||
public void checkUpdate(UpgradeApp app) {
|
||||
|
||||
// 检查任务
|
||||
startUpgrade(app, () -> onChecked(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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始检查更新
|
||||
*
|
||||
* @param app 更新的应用
|
||||
* @param runnable 检查后执行的任务
|
||||
*/
|
||||
private void startUpgrade(UpgradeApp app, Runnable runnable) {
|
||||
// 检查更新的任务
|
||||
var task = new CheckUpdateTask(app);
|
||||
|
||||
// 任务监听
|
||||
task.onListen(new TaskListener.UpgradeListener(task) {
|
||||
task.onListen(new TaskListener.UpgradeUpgradeListener(task) {
|
||||
|
||||
@Override
|
||||
protected void onSucceed() {
|
||||
@ -110,62 +135,4 @@ 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,9 +1,11 @@
|
||||
package cn.octopusyan.alistgui.viewModel;
|
||||
|
||||
import cn.octopusyan.alistgui.base.BaseViewModel;
|
||||
import cn.octopusyan.alistgui.config.Context;
|
||||
import cn.octopusyan.alistgui.manager.AListManager;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.*;
|
||||
import javafx.collections.FXCollections;
|
||||
|
||||
/**
|
||||
* 主界面VM
|
||||
@ -11,14 +13,56 @@ import javafx.beans.property.SimpleBooleanProperty;
|
||||
* @author octopus_yan
|
||||
*/
|
||||
public class MainViewModel extends BaseViewModel {
|
||||
private final ListProperty<String> startBtnStyleCss = new SimpleListProperty<>(FXCollections.observableArrayList());
|
||||
private final StringProperty startBtnText = new SimpleStringProperty();
|
||||
private final ListProperty<String> statusLabelStyleCss = new SimpleListProperty<>(FXCollections.observableArrayList());
|
||||
private final StringProperty statusLabelText = new SimpleStringProperty();
|
||||
private final BooleanProperty browserButtonDisable = new SimpleBooleanProperty();
|
||||
private final BooleanProperty running = new SimpleBooleanProperty();
|
||||
|
||||
public MainViewModel() {
|
||||
running.addListener((_, _, running) -> {
|
||||
resetStatus(running);
|
||||
browserButtonDisable.set(!running);
|
||||
});
|
||||
// 先添加监听再绑定,解决切换locale后,界面状态显示错误的问题
|
||||
running.bind(AListManager.runningProperty());
|
||||
}
|
||||
|
||||
public BooleanProperty runningProperty() {
|
||||
return running;
|
||||
public ListProperty<String> startBtnStyleCssProperty() {
|
||||
return startBtnStyleCss;
|
||||
}
|
||||
|
||||
public StringProperty startBtnTextProperty() {
|
||||
return startBtnText;
|
||||
}
|
||||
|
||||
public ListProperty<String> statusLabelStyleCssProperty() {
|
||||
return statusLabelStyleCss;
|
||||
}
|
||||
|
||||
public StringProperty statusLabelTextProperty() {
|
||||
return statusLabelText;
|
||||
}
|
||||
|
||||
public BooleanProperty browserButtonDisableProperty() {
|
||||
return browserButtonDisable;
|
||||
}
|
||||
|
||||
public void resetStatus(boolean running) {
|
||||
String removeStyle = running ? "success" : "danger";
|
||||
String addStyle = running ? "danger" : "success";
|
||||
String button = Context.getLanguageBinding(STR."main.control.\{running ? "stop" : "start"}").get();
|
||||
String status = Context.getLanguageBinding(STR."main.status.label-\{running ? "running" : "stop"}").get();
|
||||
|
||||
Platform.runLater(() -> {
|
||||
startBtnStyleCss.remove(removeStyle);
|
||||
startBtnStyleCss.add(addStyle);
|
||||
startBtnText.set(button);
|
||||
|
||||
statusLabelStyleCss.remove(addStyle);
|
||||
statusLabelStyleCss.add(removeStyle);
|
||||
statusLabelText.set(status);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ public class SetupViewModel extends BaseViewModel {
|
||||
|
||||
|
||||
public SetupViewModel() {
|
||||
theme.bindBidirectional(Context.themeProperty());
|
||||
theme.addListener((_, _, newValue) -> ConfigManager.theme(newValue));
|
||||
silentStartup.addListener((_, _, newValue) -> ConfigManager.silentStartup(newValue));
|
||||
autoStart.addListener((_, _, newValue) -> {
|
||||
|
@ -1,3 +1,3 @@
|
||||
app.name=${project.name}
|
||||
app.title=AList GUI
|
||||
app.version=v${project.version}
|
||||
app.version=${project.version}
|
@ -22,11 +22,11 @@
|
||||
</StackPane>
|
||||
|
||||
<HBox alignment="CENTER" styleClass="shield">
|
||||
<Label fx:id="aListVersionLabel" styleClass="shield-name" text="%about.alist.version"/>
|
||||
<Label styleClass="shield-name" text="%about.alist.version"/>
|
||||
<Label fx:id="aListVersion" styleClass="shield-version"/>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER" styleClass="shield">
|
||||
<Label fx:id="appVersionLabel" styleClass="shield-name" text="%about.app.version"/>
|
||||
<Label styleClass="shield-name" text="%about.app.version"/>
|
||||
<Label styleClass="shield-version" text="v${project.version}"/>
|
||||
</HBox>
|
||||
<Button fx:id="checkAppVersion" onAction="#checkGuiUpdate" styleClass="flat" text="%about.app.update"/>
|
||||
|
@ -21,13 +21,13 @@
|
||||
<VBox alignment="CENTER" spacing="20"
|
||||
AnchorPane.bottomAnchor="30" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0">
|
||||
|
||||
<Label fx:id="toptip" style="-fx-background-radius: 10;-fx-background-color: -color-button-bg-hover;"
|
||||
<Label style="-fx-background-radius: 10;-fx-background-color: -color-button-bg-hover;"
|
||||
styleClass="admin-toptip, button, flat, danger" text="%admin.pwd.toptip"/>
|
||||
|
||||
<Pane style="-fx-background-color: transparent"/>
|
||||
|
||||
<HBox alignment="CENTER" styleClass="admin-field">
|
||||
<Label fx:id="usernameLabel" text="%admin.pwd.user-field"/>
|
||||
<Label text="%admin.pwd.user-field"/>
|
||||
<InputGroup fx:id="userField" styleClass="admin-field-value">
|
||||
<TextField fx:id="usernameField" text="admin" editable="false"/>
|
||||
<Button fx:id="copyUsername" onAction="#copyUsername">
|
||||
@ -39,7 +39,7 @@
|
||||
</HBox>
|
||||
|
||||
<HBox alignment="CENTER" styleClass="admin-field">
|
||||
<Label fx:id="passwordLabel" text="%admin.pwd.pwd-field"/>
|
||||
<Label text="%admin.pwd.pwd-field"/>
|
||||
<InputGroup styleClass="admin-field-value">
|
||||
<PasswordField fx:id="passwordField" editable="false"/>
|
||||
<Button fx:id="refreshPassword" onAction="#savePassword" visible="false" managed="false">
|
||||
|
@ -34,8 +34,8 @@
|
||||
<MenuButton fx:id="moreButton" styleClass="button-outlined, no-arrow" text="%main.control.more">
|
||||
<items>
|
||||
<MenuItem fx:id="browserButton" onAction="#openInBrowser" disable="true" text="%main.more.browser"/>
|
||||
<MenuItem fx:id="configButton" onAction="#openConfig" text="%main.more.open-config"/>
|
||||
<MenuItem fx:id="logButton" onAction="#openLogFolder" text="%main.more.open-log"/>
|
||||
<MenuItem onAction="#openConfig" text="%main.more.open-config"/>
|
||||
<MenuItem onAction="#openLogFolder" text="%main.more.open-log"/>
|
||||
</items>
|
||||
</MenuButton>
|
||||
</HBox>
|
||||
|
@ -24,14 +24,14 @@
|
||||
<padding>
|
||||
<Insets left="20.0" right="20.0"/>
|
||||
</padding>
|
||||
<Tab fx:id="mainTab" text="%root.tab.main">
|
||||
<Tab text="%root.tab.main">
|
||||
<graphic>
|
||||
<FontIcon iconColor="white" iconLiteral="fa-th-large"/>
|
||||
</graphic>
|
||||
<!-- 引入主页 -->
|
||||
<fx:include fx:id="mainController" source="main-view.fxml" prefWidth="Infinity" prefHeight="-Infinity"/>
|
||||
</Tab>
|
||||
<Tab fx:id="setupTab" text="%root.tab.setup">
|
||||
<Tab text="%root.tab.setup">
|
||||
<graphic>
|
||||
<FontIcon iconColor="white" iconLiteral="fa-cog"/>
|
||||
</graphic>
|
||||
@ -39,7 +39,7 @@
|
||||
<fx:include fx:id="setupController" source="setup-view.fxml" prefWidth="Infinity"
|
||||
prefHeight="-Infinity"/>
|
||||
</Tab>
|
||||
<Tab fx:id="aboutTab" text="%root.tab.about">
|
||||
<Tab text="%root.tab.about">
|
||||
<graphic>
|
||||
<FontIcon iconColor="white" iconLiteral="fa-info-circle"/>
|
||||
</graphic>
|
||||
|
@ -38,9 +38,9 @@
|
||||
<padding>
|
||||
<Insets left="30"/>
|
||||
</padding>
|
||||
<Label fx:id="hostLabel" text="%setup.proxy.host"/>
|
||||
<Label text="%setup.proxy.host"/>
|
||||
<TextField fx:id="proxyHost" promptText="127.0.0.1" GridPane.columnIndex="1"/>
|
||||
<Label fx:id="portLabel" text="%setup.proxy.port" GridPane.rowIndex="1"/>
|
||||
<Label text="%setup.proxy.port" GridPane.rowIndex="1"/>
|
||||
<TextField fx:id="proxyPort" promptText="8080" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||
</GridPane>
|
||||
</VBox>
|
||||
|
Loading…
Reference in New Issue
Block a user