mirror of
https://github.com/octopusYan/alist-gui.git
synced 2024-12-04 01:06:42 +08:00
feat: 添加开机自启
This commit is contained in:
parent
7c051bbf44
commit
9f5eaba2c8
14
pom.xml
14
pom.xml
@ -15,7 +15,7 @@
|
||||
</organization>
|
||||
|
||||
<inceptionYear>2024</inceptionYear>
|
||||
<description>AList windows gui</description>
|
||||
<description>AList GUI</description>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
@ -35,6 +35,7 @@
|
||||
<hutool.version>5.8.32</hutool.version>
|
||||
<common-lang3.version>3.16.0</common-lang3.version>
|
||||
<common-exec.version>1.4.0</common-exec.version>
|
||||
<jna.version>5.14.0</jna.version>
|
||||
<lombok.version>1.18.32</lombok.version>
|
||||
<jackson.version>2.15.4</jackson.version>
|
||||
<ikonli.version>12.3.1</ikonli.version>
|
||||
@ -93,6 +94,17 @@
|
||||
<version>${common-exec.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna</artifactId>
|
||||
<version>${jna.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna-platform</artifactId>
|
||||
<version>${jna.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- hutool -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
|
@ -23,4 +23,7 @@ public class Constants {
|
||||
public static final String CONFIG_DIR_PATH = STR."\{DATA_DIR_PATH}\{File.separator}config";
|
||||
public static final String GUI_CONFIG_PATH = STR."\{CONFIG_DIR_PATH}\{File.separator}gui.yaml";
|
||||
public static final String BAK_FILE_PATH = STR."\{Constants.TMP_DIR_PATH}\{File.separator}bak";
|
||||
|
||||
public static final String REG_AUTO_RUN = "Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
||||
public static final String APP_EXE = STR."\{DATA_DIR_PATH}\{File.separator}\{APP_NAME}.exe";
|
||||
}
|
||||
|
@ -2,10 +2,13 @@ package cn.octopusyan.alistgui.controller;
|
||||
|
||||
import atlantafx.base.theme.Theme;
|
||||
import cn.octopusyan.alistgui.base.BaseController;
|
||||
import cn.octopusyan.alistgui.config.Constants;
|
||||
import cn.octopusyan.alistgui.config.Context;
|
||||
import cn.octopusyan.alistgui.enums.ProxySetup;
|
||||
import cn.octopusyan.alistgui.manager.ConfigManager;
|
||||
import cn.octopusyan.alistgui.viewModel.SetupViewModel;
|
||||
import com.sun.jna.platform.win32.Advapi32Util;
|
||||
import com.sun.jna.platform.win32.WinReg;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
@ -98,6 +101,18 @@ public class SetupController extends BaseController<SetupViewModel> implements I
|
||||
viewModel.languageProperty().bind(languageComboBox.getSelectionModel().selectedItemProperty());
|
||||
viewModel.themeProperty().bind(themeComboBox.getSelectionModel().selectedItemProperty());
|
||||
viewModel.proxySetupProperty().bind(proxySetupComboBox.getSelectionModel().selectedItemProperty());
|
||||
|
||||
autoStartCheckBox.selectedProperty().addListener((_, _, checked) -> {
|
||||
try {
|
||||
if (checked) {
|
||||
Advapi32Util.registrySetStringValue(WinReg.HKEY_CURRENT_USER, Constants.REG_AUTO_RUN, Constants.APP_TITLE, Constants.APP_EXE);
|
||||
} else {
|
||||
Advapi32Util.registryDeleteValue(WinReg.HKEY_CURRENT_USER, Constants.REG_AUTO_RUN, Constants.APP_TITLE);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
@ -1,5 +1,6 @@
|
||||
module cn.octopusyan.alistgui {
|
||||
requires java.net.http;
|
||||
requires com.sun.jna.platform;
|
||||
requires javafx.controls;
|
||||
requires javafx.fxml;
|
||||
requires javafx.graphics;
|
||||
|
Loading…
Reference in New Issue
Block a user