From 185654ec95f7fe7b4a763ca73e52a62f7224531a Mon Sep 17 00:00:00 2001 From: mine_ Date: Thu, 25 Sep 2025 19:38:20 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0mainPanel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vortex/model/ui/ContentPanel.java | 3 +- .../vortex/ui/controller/MainPanel.java | 38 +++++++++++ .../vortex/ui/controller/MainWindow.java | 7 ++ src/main/resources/lang/I18N.properties | 1 + src/main/resources/lang/I18N_en.properties | 1 + src/main/resources/lang/I18N_zh_CN.properties | 1 + src/main/resources/lang/I18N_zh_TW.properties | 1 + .../minediamond/vortex/css/fluent-style.css | 15 ++++ .../minediamond/vortex/ui/main-window.fxml | 7 ++ .../tech/minediamond/vortex/ui/mainPanel.fxml | 68 +++++++++++++++++++ 10 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 src/main/java/tech/minediamond/vortex/ui/controller/MainPanel.java create mode 100644 src/main/resources/tech/minediamond/vortex/ui/mainPanel.fxml diff --git a/src/main/java/tech/minediamond/vortex/model/ui/ContentPanel.java b/src/main/java/tech/minediamond/vortex/model/ui/ContentPanel.java index bad95ef..1f7965c 100644 --- a/src/main/java/tech/minediamond/vortex/model/ui/ContentPanel.java +++ b/src/main/java/tech/minediamond/vortex/model/ui/ContentPanel.java @@ -22,7 +22,8 @@ public enum ContentPanel { EDITOR_PANEL("editorPanel.fxml"), SETTING_PANEL("settingPanel.fxml"), - SEARCH_PANEL("searchPanel.fxml"); + SEARCH_PANEL("searchPanel.fxml"), + MAIN_PANEL("mainPanel.fxml"); private final String fileName; diff --git a/src/main/java/tech/minediamond/vortex/ui/controller/MainPanel.java b/src/main/java/tech/minediamond/vortex/ui/controller/MainPanel.java new file mode 100644 index 0000000..d898e42 --- /dev/null +++ b/src/main/java/tech/minediamond/vortex/ui/controller/MainPanel.java @@ -0,0 +1,38 @@ +/* + * Vortex + * Copyright (C) 2025 Mine-diamond + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package tech.minediamond.vortex.ui.controller; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import javafx.fxml.FXML; +import javafx.scene.layout.GridPane; + +@Singleton +public class MainPanel { + + @FXML + public GridPane mainGrid; + + @Inject + public MainPanel() { + + } + +} diff --git a/src/main/java/tech/minediamond/vortex/ui/controller/MainWindow.java b/src/main/java/tech/minediamond/vortex/ui/controller/MainWindow.java index ecaee1d..5323c9b 100644 --- a/src/main/java/tech/minediamond/vortex/ui/controller/MainWindow.java +++ b/src/main/java/tech/minediamond/vortex/ui/controller/MainWindow.java @@ -80,6 +80,8 @@ public class MainWindow { @FXML private ToggleGroup mainToggleGroup; @FXML + private ToggleButton mainPanelBtn; + @FXML private ToggleButton quickEditBtn; @FXML private ToggleButton searchBtn; @@ -194,6 +196,7 @@ public void initUIComponent() { case EDITOR_PANEL -> mainToggleGroup.selectToggle(quickEditBtn); case SETTING_PANEL -> mainToggleGroup.selectToggle(settingBtn); case SEARCH_PANEL -> mainToggleGroup.selectToggle(searchBtn); + case MAIN_PANEL -> mainToggleGroup.selectToggle(mainPanelBtn); } }); @@ -300,6 +303,10 @@ private void loadOrGetView(ContentPanel fxmlFileName) { tabWindow.getChildren().setAll(view); } + public void showMainPanel(ActionEvent actionEvent) { + currentContentPanelProperty.set(ContentPanel.MAIN_PANEL); + } + public void showEditorPanel(ActionEvent actionEvent) { currentContentPanelProperty.set(ContentPanel.EDITOR_PANEL); } diff --git a/src/main/resources/lang/I18N.properties b/src/main/resources/lang/I18N.properties index 59be553..cdfc2ff 100644 --- a/src/main/resources/lang/I18N.properties +++ b/src/main/resources/lang/I18N.properties @@ -33,6 +33,7 @@ lang.auto=use system language lang.zh_TW=\u7E41\u4F53\u4E2D\u6587 window.pin=pinned window.unpin=unpin +mainWindow.tab.mainPanel=main Window mainWindow.tab.search=search mainWindow.tab.quickEdit=quick edit mainWindow.tab.setting=setting diff --git a/src/main/resources/lang/I18N_en.properties b/src/main/resources/lang/I18N_en.properties index 71e7074..7448cf8 100644 --- a/src/main/resources/lang/I18N_en.properties +++ b/src/main/resources/lang/I18N_en.properties @@ -34,6 +34,7 @@ lang.auto=use system language lang.zh_TW=\u7E41\u9AD4\u4E2D\u6587 window.pin=pinned window.unpin=unpin +mainWindow.tab.mainPanel=main Window mainWindow.tab.search=search mainWindow.tab.quickEdit=quick edit mainWindow.tab.setting=setting diff --git a/src/main/resources/lang/I18N_zh_CN.properties b/src/main/resources/lang/I18N_zh_CN.properties index 18f1117..3f307aa 100644 --- a/src/main/resources/lang/I18N_zh_CN.properties +++ b/src/main/resources/lang/I18N_zh_CN.properties @@ -34,6 +34,7 @@ lang.auto=\u4F7F\u7528\u7CFB\u7EDF\u8BED\u8A00 lang.zh_TW=\u7E41\u9AD4\u4E2D\u6587 window.pin=\u5DF2\u56FA\u5B9A window.unpin=\u672A\u56FA\u5B9A +mainWindow.tab.mainPanel=\u4E3B\u7A97\u53E3 mainWindow.tab.search=\u641C\u7D22 mainWindow.tab.quickEdit=\u5FEB\u901F\u7F16\u8F91 mainWindow.tab.setting=\u8BBE\u7F6E diff --git a/src/main/resources/lang/I18N_zh_TW.properties b/src/main/resources/lang/I18N_zh_TW.properties index a9115c3..c71e8f4 100644 --- a/src/main/resources/lang/I18N_zh_TW.properties +++ b/src/main/resources/lang/I18N_zh_TW.properties @@ -34,6 +34,7 @@ lang.auto=\u4F7F\u7528\u7CFB\u7D71\u8A9E\u8A00 lang.zh_TW=\u7E41\u9AD4\u4E2D\u6587 window.pin=\u5DF2\u91D8\u9078 window.unpin=\u672A\u91D8\u9078 +mainWindow.tab.mainPanel=\u4E3B\u8996\u7A97 mainWindow.tab.search=\u641C\u5C0B mainWindow.tab.quickEdit=\u5FEB\u901F\u7DE8\u8F2F mainWindow.tab.setting=\u8A2D\u5B9A diff --git a/src/main/resources/tech/minediamond/vortex/css/fluent-style.css b/src/main/resources/tech/minediamond/vortex/css/fluent-style.css index 23de79d..6de9c6d 100644 --- a/src/main/resources/tech/minediamond/vortex/css/fluent-style.css +++ b/src/main/resources/tech/minediamond/vortex/css/fluent-style.css @@ -133,6 +133,21 @@ -fx-icon-size: 16; } +#svgIcon { + -fx-icon-color: -app-text-fill-color; + -fx-icon-size: 16px; + -fx-pref-height: 16px; + -fx-pref-width: 16px; + -fx-max-height: 16px; + -fx-min-height: 16px; + -fx-max-width: 16px; + -fx-min-width: 16px; + -fx-fill: white; + -fx-border-color: white; + -fx-border-width: 1px; + -fx-shape: "m 112,78 a 5,5 0 0 1 -5,5 5,5 0 0 1 -5,-5 5,5 0 0 1 5,-5 5,5 0 0 1 5,5 z m -5,-30 a 7,7 0 0 1 -7,7 7,7 0 0 1 -7,-7 7,7 0 0 1 7,-7 7,7 0 0 1 7,7 z m -32.052559,52.6077 a 5,5 0 0 1 6.830127,1.83012 5,5 0 0 1 -1.830127,6.83013 5,5 0 0 1 -6.830127,-1.83013 5,5 0 0 1 1.830127,-6.83012 z m -23.480762,19.33012 a 7,7 0 0 1 9.562178,2.56218 7,7 0 0 1 -2.562178,9.56218 7,7 0 0 1 -9.562178,-2.56218 7,7 0 0 1 2.562178,-9.56218 z m 61.585881,1.45448 a 5,5 0 0 1 -1.83013,-6.83012 5,5 0 0 1 6.83013,-1.83013 5,5 0 0 1 1.83013,6.83013 5,5 0 0 1 -6.83013,1.83012 z m 28.48076,10.66988 a 7,7 0 0 1 -2.56218,-9.56218 7,7 0 0 1 9.56218,-2.56218 7,7 0 0 1 2.56218,9.56218 7,7 0 0 1 -9.56218,2.56218 z M 93,112.12436 A 14,14 0 0 1 87.875644,93 14,14 0 0 1 107,87.875644 14,14 0 0 1 112.12436,107 14,14 0 0 1 93,112.12436 Z M 100,20 c 60,5 85,60 10,80 H 100 V 85 C 55,85 70,30 100,20 Z M 30.717968,140 C 5.0480947,85.538476 40.179492,36.387841 95,91.339746 L 100,100 87.009619,107.5 C 109.50962,146.47114 54.378222,160.98076 30.717968,140 Z m 138.564062,0 C 134.95191,189.46152 74.820508,183.61216 95,108.66025 L 100,100 l 12.99038,7.5 c 22.5,-38.971143 62.6314,1.51924 56.29165,32.5 z"; +} + .button:hover, .toggle-button:hover { -fx-background-color: -button-bg-color-hover; -fx-effect: dropshadow(gaussian, -button-bg-color-hover, 3, 0, 0, 0); diff --git a/src/main/resources/tech/minediamond/vortex/ui/main-window.fxml b/src/main/resources/tech/minediamond/vortex/ui/main-window.fxml index a95e07c..f29e77f 100644 --- a/src/main/resources/tech/minediamond/vortex/ui/main-window.fxml +++ b/src/main/resources/tech/minediamond/vortex/ui/main-window.fxml @@ -23,6 +23,8 @@ + + + + + + + diff --git a/src/main/resources/tech/minediamond/vortex/ui/mainPanel.fxml b/src/main/resources/tech/minediamond/vortex/ui/mainPanel.fxml new file mode 100644 index 0000000..631dad0 --- /dev/null +++ b/src/main/resources/tech/minediamond/vortex/ui/mainPanel.fxml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 4965478dc87e8ec78653b32848e2291e0d70310e Mon Sep 17 00:00:00 2001 From: mine_ Date: Fri, 26 Sep 2025 13:03:18 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E9=87=8D=E5=91=BD=E5=90=8D`Program?= =?UTF-8?q?Info.java`=20->=20`ProgramData.java`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/appConfig/GlobalDataStore.java | 4 +- .../{ProgramInfo.java => ProgramData.java} | 4 +- .../program/FindApplicationsService.java | 26 +++++----- .../vortex/ui/controller/MainWindow.java | 3 +- .../vortex/util/LaunchProgramUtil.java | 24 ++++----- .../minediamond/vortex/css/fluent-style.css | 37 +++++++------ .../minediamond/vortex/ui/main-window.fxml | 2 +- .../tech/minediamond/vortex/ui/mainPanel.fxml | 52 +++++++++---------- 8 files changed, 76 insertions(+), 76 deletions(-) rename src/main/java/tech/minediamond/vortex/model/program/{ProgramInfo.java => ProgramData.java} (96%) diff --git a/src/main/java/tech/minediamond/vortex/model/appConfig/GlobalDataStore.java b/src/main/java/tech/minediamond/vortex/model/appConfig/GlobalDataStore.java index 0acf7f6..3d46454 100644 --- a/src/main/java/tech/minediamond/vortex/model/appConfig/GlobalDataStore.java +++ b/src/main/java/tech/minediamond/vortex/model/appConfig/GlobalDataStore.java @@ -21,7 +21,7 @@ import lombok.Getter; import lombok.Setter; -import tech.minediamond.vortex.model.program.ProgramInfo; +import tech.minediamond.vortex.model.program.ProgramData; import java.util.ArrayList; @@ -29,5 +29,5 @@ @Setter public class GlobalDataStore { //存放全局的应用信息数据 - public static ArrayList programInfos = new ArrayList<>(); + public static ArrayList programData = new ArrayList<>(); } diff --git a/src/main/java/tech/minediamond/vortex/model/program/ProgramInfo.java b/src/main/java/tech/minediamond/vortex/model/program/ProgramData.java similarity index 96% rename from src/main/java/tech/minediamond/vortex/model/program/ProgramInfo.java rename to src/main/java/tech/minediamond/vortex/model/program/ProgramData.java index 8e90326..d3eb22f 100644 --- a/src/main/java/tech/minediamond/vortex/model/program/ProgramInfo.java +++ b/src/main/java/tech/minediamond/vortex/model/program/ProgramData.java @@ -31,7 +31,7 @@ @Setter @ToString @EqualsAndHashCode -public class ProgramInfo { +public class ProgramData { private String baseName; @@ -53,7 +53,7 @@ public class ProgramInfo { private String id; - public boolean equal(ProgramInfo other) { + public boolean equal(ProgramData other) { if(this.baseName.equals(other.baseName) && (this.version.equals(other.version) || (this.version == null && other.version == null)) diff --git a/src/main/java/tech/minediamond/vortex/service/program/FindApplicationsService.java b/src/main/java/tech/minediamond/vortex/service/program/FindApplicationsService.java index 6105c08..74e7443 100644 --- a/src/main/java/tech/minediamond/vortex/service/program/FindApplicationsService.java +++ b/src/main/java/tech/minediamond/vortex/service/program/FindApplicationsService.java @@ -25,7 +25,7 @@ import com.google.inject.Singleton; import lombok.extern.slf4j.Slf4j; import tech.minediamond.vortex.model.appConfig.GlobalDataStore; -import tech.minediamond.vortex.model.program.ProgramInfo; +import tech.minediamond.vortex.model.program.ProgramData; import tech.minediamond.vortex.model.program.ProgramSource; import java.io.BufferedReader; @@ -137,26 +137,26 @@ public void getInstalledPrograms() throws IOException, InterruptedException { log.info("powershell执行时间:{}ms", Duration.between(time, time2).toMillis()); ObjectMapper mapper = new ObjectMapper(); - List programs = mapper.readValue(jsonOutput, new TypeReference>() {}); + List programs = mapper.readValue(jsonOutput, new TypeReference>() {}); - programs.sort(Comparator.comparing(ProgramInfo::getBaseName, Comparator.nullsLast(String::compareToIgnoreCase))); - programs.removeIf((programInfo) -> { - return (programInfo.getSource() == ProgramSource.REGISTRY && (programInfo.getProgramName() == null || programInfo.getInstallLocation() == null || programInfo.getInstallLocation().equals(""))); + programs.sort(Comparator.comparing(ProgramData::getBaseName, Comparator.nullsLast(String::compareToIgnoreCase))); + programs.removeIf((programData) -> { + return (programData.getSource() == ProgramSource.REGISTRY && (programData.getProgramName() == null || programData.getInstallLocation() == null || programData.getInstallLocation().equals(""))); }); - for (ProgramInfo programInfo : programs) { + for (ProgramData programData : programs) { - programInfo.setDisplayName(programInfo.getBaseName()); - if (programInfo.getInstallLocation() != null && programInfo.getInstallLocation().equals("")) { - programInfo.setInstallLocation(null); + programData.setDisplayName(programData.getBaseName()); + if (programData.getInstallLocation() != null && programData.getInstallLocation().equals("")) { + programData.setInstallLocation(null); } - if (programInfo.getSource() == ProgramSource.REGISTRY && !programInfo.getInstallLocation().endsWith("\\")) { - programInfo.setInstallLocation(programInfo.getInstallLocation() + "\\"); + if (programData.getSource() == ProgramSource.REGISTRY && !programData.getInstallLocation().endsWith("\\")) { + programData.setInstallLocation(programData.getInstallLocation() + "\\"); } } - GlobalDataStore.programInfos.addAll(programs); + GlobalDataStore.programData.addAll(programs); LocalTime time3 = LocalTime.now(); log.info("数据处理时间:{}ms", Duration.between(time2, time3).toMillis()); @@ -166,7 +166,7 @@ public void getInstalledPrograms() throws IOException, InterruptedException { public static void main(String[] args) throws IOException, InterruptedException, SQLException { LocalTime start = LocalTime.now(); new FindApplicationsService().getInstalledPrograms(); - GlobalDataStore.programInfos.forEach(System.out::println); + GlobalDataStore.programData.forEach(System.out::println); LocalTime end = LocalTime.now(); log.info("程序运行总时间: {}ms", Duration.between(start, end).toMillis()); } diff --git a/src/main/java/tech/minediamond/vortex/ui/controller/MainWindow.java b/src/main/java/tech/minediamond/vortex/ui/controller/MainWindow.java index 5323c9b..495b0aa 100644 --- a/src/main/java/tech/minediamond/vortex/ui/controller/MainWindow.java +++ b/src/main/java/tech/minediamond/vortex/ui/controller/MainWindow.java @@ -128,8 +128,7 @@ public void initialize() { handleDragWindow(); initUIComponent(); - loadOrGetView(currentContentPanelProperty.get()); - mainToggleGroup.selectToggle(quickEditBtn); + currentContentPanelProperty.set(ContentPanel.MAIN_PANEL); } /** diff --git a/src/main/java/tech/minediamond/vortex/util/LaunchProgramUtil.java b/src/main/java/tech/minediamond/vortex/util/LaunchProgramUtil.java index b153533..a35749e 100644 --- a/src/main/java/tech/minediamond/vortex/util/LaunchProgramUtil.java +++ b/src/main/java/tech/minediamond/vortex/util/LaunchProgramUtil.java @@ -21,7 +21,7 @@ import lombok.extern.slf4j.Slf4j; import tech.minediamond.vortex.model.appConfig.GlobalDataStore; -import tech.minediamond.vortex.model.program.ProgramInfo; +import tech.minediamond.vortex.model.program.ProgramData; import java.io.File; import java.io.IOException; @@ -34,45 +34,45 @@ public class LaunchProgramUtil { private static final String UWP_COMMAND_PREFIX = "shell:AppsFolder\\"; private static final String EXPLORER_EXECUTABLE = "explorer.exe"; - public static ProgramInfo getProgramInfoByID(String id) throws IOException { - ProgramInfo programInfo = new ProgramInfo(); + public static ProgramData getProgramInfoByID(String id) throws IOException { + ProgramData programData = new ProgramData(); boolean found = false; - for(ProgramInfo info : GlobalDataStore.programInfos) { + for(ProgramData info : GlobalDataStore.programData) { if(info.getId().equals(id)) { - programInfo = info; + programData = info; found = true; } } if(found) { - return programInfo; + return programData; }else { return null; } } - public static boolean openApplication(ProgramInfo programInfo) { + public static boolean openApplication(ProgramData programData) { ProcessBuilder pb = new ProcessBuilder(); - switch (programInfo.getSource()) { + switch (programData.getSource()) { case UWP -> { log.info("启动UWP应用"); - String aumid = programInfo.getProgramName(); + String aumid = programData.getProgramName(); pb = new ProcessBuilder(EXPLORER_EXECUTABLE, UWP_COMMAND_PREFIX + aumid); } case REGISTRY -> { log.info("启动Registry应用"); - Path path = Path.of(programInfo.getInstallLocation(),programInfo.getProgramName()); + Path path = Path.of(programData.getInstallLocation(), programData.getProgramName()); log.debug(String.valueOf(path)); pb = new ProcessBuilder(path.toString()); - File workingDirectory = new File(programInfo.getInstallLocation()); + File workingDirectory = new File(programData.getInstallLocation()); pb.directory(workingDirectory); } - default -> throw new IllegalArgumentException("不支持的 ProgramSource 类型: " + programInfo.getSource()); + default -> throw new IllegalArgumentException("不支持的 ProgramSource 类型: " + programData.getSource()); } try { diff --git a/src/main/resources/tech/minediamond/vortex/css/fluent-style.css b/src/main/resources/tech/minediamond/vortex/css/fluent-style.css index 6de9c6d..5647509 100644 --- a/src/main/resources/tech/minediamond/vortex/css/fluent-style.css +++ b/src/main/resources/tech/minediamond/vortex/css/fluent-style.css @@ -133,21 +133,6 @@ -fx-icon-size: 16; } -#svgIcon { - -fx-icon-color: -app-text-fill-color; - -fx-icon-size: 16px; - -fx-pref-height: 16px; - -fx-pref-width: 16px; - -fx-max-height: 16px; - -fx-min-height: 16px; - -fx-max-width: 16px; - -fx-min-width: 16px; - -fx-fill: white; - -fx-border-color: white; - -fx-border-width: 1px; - -fx-shape: "m 112,78 a 5,5 0 0 1 -5,5 5,5 0 0 1 -5,-5 5,5 0 0 1 5,-5 5,5 0 0 1 5,5 z m -5,-30 a 7,7 0 0 1 -7,7 7,7 0 0 1 -7,-7 7,7 0 0 1 7,-7 7,7 0 0 1 7,7 z m -32.052559,52.6077 a 5,5 0 0 1 6.830127,1.83012 5,5 0 0 1 -1.830127,6.83013 5,5 0 0 1 -6.830127,-1.83013 5,5 0 0 1 1.830127,-6.83012 z m -23.480762,19.33012 a 7,7 0 0 1 9.562178,2.56218 7,7 0 0 1 -2.562178,9.56218 7,7 0 0 1 -9.562178,-2.56218 7,7 0 0 1 2.562178,-9.56218 z m 61.585881,1.45448 a 5,5 0 0 1 -1.83013,-6.83012 5,5 0 0 1 6.83013,-1.83013 5,5 0 0 1 1.83013,6.83013 5,5 0 0 1 -6.83013,1.83012 z m 28.48076,10.66988 a 7,7 0 0 1 -2.56218,-9.56218 7,7 0 0 1 9.56218,-2.56218 7,7 0 0 1 2.56218,9.56218 7,7 0 0 1 -9.56218,2.56218 z M 93,112.12436 A 14,14 0 0 1 87.875644,93 14,14 0 0 1 107,87.875644 14,14 0 0 1 112.12436,107 14,14 0 0 1 93,112.12436 Z M 100,20 c 60,5 85,60 10,80 H 100 V 85 C 55,85 70,30 100,20 Z M 30.717968,140 C 5.0480947,85.538476 40.179492,36.387841 95,91.339746 L 100,100 87.009619,107.5 C 109.50962,146.47114 54.378222,160.98076 30.717968,140 Z m 138.564062,0 C 134.95191,189.46152 74.820508,183.61216 95,108.66025 L 100,100 l 12.99038,7.5 c 22.5,-38.971143 62.6314,1.51924 56.29165,32.5 z"; -} - .button:hover, .toggle-button:hover { -fx-background-color: -button-bg-color-hover; -fx-effect: dropshadow(gaussian, -button-bg-color-hover, 3, 0, 0, 0); @@ -488,11 +473,30 @@ -fx-border-width: 0; } +/**/ +/**/ +/* + * =================================================================== + * SVG ICON -> 自定义图标样式 + * =================================================================== + */ + +.svg-icon { + -fx-pref-height: 16px; + -fx-pref-width: 16px; + -fx-border-color: -app-text-fill-color; + -fx-border-width: 1px; +} + +#appIcon { + -fx-shape: "M 93,112.12436 A 14,14 0 0 1 87.875644,93 14,14 0 0 1 107,87.875644 14,14 0 0 1 112.12436,107 14,14 0 0 1 93,112.12436 Z M 100,20 c 60,5 85,60 10,80 H 100 V 85 C 55,85 70,30 100,20 Z M 30.717968,140 C 5.0480947,85.538476 40.179492,36.387841 95,91.339746 L 100,100 87.009619,107.5 C 109.50962,146.47114 54.378222,160.98076 30.717968,140 Z m 138.564062,0 C 134.95191,189.46152 74.820508,183.61216 95,108.66025 L 100,100 l 12.99038,7.5 c 22.5,-38.971143 62.6314,1.51924 56.29165,32.5 z"; +} + /**/ /**/ /* * =================================================================== - * 11. UTILITY & OVERRIDES -> 特殊样式及覆盖 + * UTILITY & OVERRIDES -> 特殊样式及覆盖 * =================================================================== */ @@ -509,4 +513,5 @@ -fx-background-color: -fx-exit-button-bg-color-pressed; } + /**/ diff --git a/src/main/resources/tech/minediamond/vortex/ui/main-window.fxml b/src/main/resources/tech/minediamond/vortex/ui/main-window.fxml index f29e77f..dfecaf7 100644 --- a/src/main/resources/tech/minediamond/vortex/ui/main-window.fxml +++ b/src/main/resources/tech/minediamond/vortex/ui/main-window.fxml @@ -41,7 +41,7 @@ - + diff --git a/src/main/resources/tech/minediamond/vortex/ui/mainPanel.fxml b/src/main/resources/tech/minediamond/vortex/ui/mainPanel.fxml index 631dad0..3f8a358 100644 --- a/src/main/resources/tech/minediamond/vortex/ui/mainPanel.fxml +++ b/src/main/resources/tech/minediamond/vortex/ui/mainPanel.fxml @@ -1,11 +1,5 @@ - - - - - - + - + - + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - + + + + + + + + From 0799faef9ec2e795af731ce7a43a8505bcc9fce7 Mon Sep 17 00:00:00 2001 From: mine_ Date: Fri, 26 Sep 2025 22:07:02 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20=E5=88=9B=E5=BB=BA=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...GlobalDataStore.java => MainPageData.java} | 2 +- .../model/appConfig/MainResourceData.java | 30 ++++++++ .../vortex/model/data/PageDirectory.java | 27 +++++++ .../vortex/model/data/PosData.java | 24 ++++++ .../program/FindApplicationsService.java | 6 +- .../vortex/ui/component/IconGrid.java | 77 +++++++++++++++++++ .../vortex/util/LaunchProgramUtil.java | 4 +- .../tech/minediamond/vortex/ui/mainPanel.fxml | 39 +--------- 8 files changed, 167 insertions(+), 42 deletions(-) rename src/main/java/tech/minediamond/vortex/model/appConfig/{GlobalDataStore.java => MainPageData.java} (97%) create mode 100644 src/main/java/tech/minediamond/vortex/model/appConfig/MainResourceData.java create mode 100644 src/main/java/tech/minediamond/vortex/model/data/PageDirectory.java create mode 100644 src/main/java/tech/minediamond/vortex/model/data/PosData.java create mode 100644 src/main/java/tech/minediamond/vortex/ui/component/IconGrid.java diff --git a/src/main/java/tech/minediamond/vortex/model/appConfig/GlobalDataStore.java b/src/main/java/tech/minediamond/vortex/model/appConfig/MainPageData.java similarity index 97% rename from src/main/java/tech/minediamond/vortex/model/appConfig/GlobalDataStore.java rename to src/main/java/tech/minediamond/vortex/model/appConfig/MainPageData.java index 3d46454..b77213a 100644 --- a/src/main/java/tech/minediamond/vortex/model/appConfig/GlobalDataStore.java +++ b/src/main/java/tech/minediamond/vortex/model/appConfig/MainPageData.java @@ -27,7 +27,7 @@ @Getter @Setter -public class GlobalDataStore { +public class MainPageData { //存放全局的应用信息数据 public static ArrayList programData = new ArrayList<>(); } diff --git a/src/main/java/tech/minediamond/vortex/model/appConfig/MainResourceData.java b/src/main/java/tech/minediamond/vortex/model/appConfig/MainResourceData.java new file mode 100644 index 0000000..234e224 --- /dev/null +++ b/src/main/java/tech/minediamond/vortex/model/appConfig/MainResourceData.java @@ -0,0 +1,30 @@ +/* + * Vortex + * Copyright (C) 2025 Mine-diamond + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package tech.minediamond.vortex.model.appConfig; + +import tech.minediamond.vortex.model.fileData.FileData; +import tech.minediamond.vortex.model.program.ProgramData; + +import java.util.ArrayList; + +public class MainResourceData { + public static ArrayList programData = new ArrayList<>(); + public static ArrayList fileData = new ArrayList<>(); +} diff --git a/src/main/java/tech/minediamond/vortex/model/data/PageDirectory.java b/src/main/java/tech/minediamond/vortex/model/data/PageDirectory.java new file mode 100644 index 0000000..aed820b --- /dev/null +++ b/src/main/java/tech/minediamond/vortex/model/data/PageDirectory.java @@ -0,0 +1,27 @@ +/* + * Vortex + * Copyright (C) 2025 Mine-diamond + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package tech.minediamond.vortex.model.data; + +public class PageDirectory { + public String name; + public String type; + + +} diff --git a/src/main/java/tech/minediamond/vortex/model/data/PosData.java b/src/main/java/tech/minediamond/vortex/model/data/PosData.java new file mode 100644 index 0000000..7f97087 --- /dev/null +++ b/src/main/java/tech/minediamond/vortex/model/data/PosData.java @@ -0,0 +1,24 @@ +/* + * Vortex + * Copyright (C) 2025 Mine-diamond + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package tech.minediamond.vortex.model.data; + +public class PosData { + +} diff --git a/src/main/java/tech/minediamond/vortex/service/program/FindApplicationsService.java b/src/main/java/tech/minediamond/vortex/service/program/FindApplicationsService.java index 74e7443..9307f7a 100644 --- a/src/main/java/tech/minediamond/vortex/service/program/FindApplicationsService.java +++ b/src/main/java/tech/minediamond/vortex/service/program/FindApplicationsService.java @@ -24,7 +24,7 @@ import com.google.inject.Inject; import com.google.inject.Singleton; import lombok.extern.slf4j.Slf4j; -import tech.minediamond.vortex.model.appConfig.GlobalDataStore; +import tech.minediamond.vortex.model.appConfig.MainPageData; import tech.minediamond.vortex.model.program.ProgramData; import tech.minediamond.vortex.model.program.ProgramSource; @@ -156,7 +156,7 @@ public void getInstalledPrograms() throws IOException, InterruptedException { } } - GlobalDataStore.programData.addAll(programs); + MainPageData.programData.addAll(programs); LocalTime time3 = LocalTime.now(); log.info("数据处理时间:{}ms", Duration.between(time2, time3).toMillis()); @@ -166,7 +166,7 @@ public void getInstalledPrograms() throws IOException, InterruptedException { public static void main(String[] args) throws IOException, InterruptedException, SQLException { LocalTime start = LocalTime.now(); new FindApplicationsService().getInstalledPrograms(); - GlobalDataStore.programData.forEach(System.out::println); + MainPageData.programData.forEach(System.out::println); LocalTime end = LocalTime.now(); log.info("程序运行总时间: {}ms", Duration.between(start, end).toMillis()); } diff --git a/src/main/java/tech/minediamond/vortex/ui/component/IconGrid.java b/src/main/java/tech/minediamond/vortex/ui/component/IconGrid.java new file mode 100644 index 0000000..f41b1ba --- /dev/null +++ b/src/main/java/tech/minediamond/vortex/ui/component/IconGrid.java @@ -0,0 +1,77 @@ +/* + * Vortex + * Copyright (C) 2025 Mine-diamond + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package tech.minediamond.vortex.ui.component; + +import com.google.inject.Inject; +import javafx.geometry.Insets; +import javafx.scene.control.Control; +import javafx.scene.control.SkinBase; +import javafx.scene.layout.ColumnConstraints; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.RowConstraints; +import javafx.scene.layout.StackPane; + +public class IconGrid extends Control { + + @Inject + public IconGrid() { + + } + + @Override + protected Skin createDefaultSkin() { + return new Skin(this); + } + + private final class Skin extends SkinBase { + + /** + * Constructor for all SkinBase instances. + * + * @param control The control for which this Skin should attach to. + */ + protected Skin(IconGrid control) { + super(control); + + StackPane stackPane = new StackPane(); + + GridPane gridPane = new GridPane(); + gridPane.setGridLinesVisible(true); + gridPane.setPadding(new Insets(20, 20, 20, 20)); + gridPane.setPrefSize(1030,560); + + for (int i = 0; i < 12; i++) { + ColumnConstraints columnConstraints = new ColumnConstraints(); + columnConstraints.setPercentWidth(20); + gridPane.getColumnConstraints().add(columnConstraints); + } + + for (int i = 0; i < 8; i++) { + RowConstraints rowConstraints = new RowConstraints(); + rowConstraints.setPercentHeight(20); + gridPane.getRowConstraints().add(rowConstraints); + } + + stackPane.getChildren().add(gridPane); + getChildren().add(stackPane); + + } + } +} diff --git a/src/main/java/tech/minediamond/vortex/util/LaunchProgramUtil.java b/src/main/java/tech/minediamond/vortex/util/LaunchProgramUtil.java index a35749e..af0b52a 100644 --- a/src/main/java/tech/minediamond/vortex/util/LaunchProgramUtil.java +++ b/src/main/java/tech/minediamond/vortex/util/LaunchProgramUtil.java @@ -20,7 +20,7 @@ package tech.minediamond.vortex.util; import lombok.extern.slf4j.Slf4j; -import tech.minediamond.vortex.model.appConfig.GlobalDataStore; +import tech.minediamond.vortex.model.appConfig.MainPageData; import tech.minediamond.vortex.model.program.ProgramData; import java.io.File; @@ -37,7 +37,7 @@ public class LaunchProgramUtil { public static ProgramData getProgramInfoByID(String id) throws IOException { ProgramData programData = new ProgramData(); boolean found = false; - for(ProgramData info : GlobalDataStore.programData) { + for(ProgramData info : MainPageData.programData) { if(info.getId().equals(id)) { programData = info; found = true; diff --git a/src/main/resources/tech/minediamond/vortex/ui/mainPanel.fxml b/src/main/resources/tech/minediamond/vortex/ui/mainPanel.fxml index 3f8a358..735dba3 100644 --- a/src/main/resources/tech/minediamond/vortex/ui/mainPanel.fxml +++ b/src/main/resources/tech/minediamond/vortex/ui/mainPanel.fxml @@ -21,44 +21,11 @@ + + fx:controller="tech.minediamond.vortex.ui.controller.MainPanel"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + From 80f6b4945bfa4b5ea5701f542bc773e9d2cbe9c8 Mon Sep 17 00:00:00 2001 From: mine_ Date: Mon, 29 Sep 2025 20:16:45 +0800 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20=E7=8E=B0=E5=9C=A8=E4=BC=9A?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=92=8C=E5=8A=A0=E8=BD=BD=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/tech/minediamond/vortex/Main.java | 2 + .../minediamond/vortex/config/AppModule.java | 5 ++ .../vortex/model/appConfig/MainPageData.java | 12 +++-- .../vortex/model/data/DirectoryOrganize.java | 24 +++++++++ .../vortex/model/data/PageDirectory.java | 9 +++- .../vortex/model/data/PosData.java | 7 ++- .../vortex/service/data/DataProvider.java | 49 +++++++++++++++++ .../vortex/service/data/DataService.java | 52 +++++++++++++++++++ .../program/FindApplicationsService.java | 4 +- .../vortex/ui/component/IconGrid.java | 9 ++-- .../vortex/ui/controller/MainPanel.java | 13 +++-- .../vortex/util/LaunchProgramUtil.java | 30 +++++------ .../tech/minediamond/vortex/ui/mainPanel.fxml | 4 +- 13 files changed, 188 insertions(+), 32 deletions(-) create mode 100644 src/main/java/tech/minediamond/vortex/model/data/DirectoryOrganize.java create mode 100644 src/main/java/tech/minediamond/vortex/service/data/DataProvider.java create mode 100644 src/main/java/tech/minediamond/vortex/service/data/DataService.java diff --git a/src/main/java/tech/minediamond/vortex/Main.java b/src/main/java/tech/minediamond/vortex/Main.java index 2fdd4af..3e168bb 100644 --- a/src/main/java/tech/minediamond/vortex/Main.java +++ b/src/main/java/tech/minediamond/vortex/Main.java @@ -35,6 +35,7 @@ import tech.minediamond.vortex.bootstrap.SingleInstanceSocketManager; import tech.minediamond.vortex.config.AppModule; import tech.minediamond.vortex.service.appConfig.AppConfigService; +import tech.minediamond.vortex.service.data.DataService; import tech.minediamond.vortex.service.i18n.I18nService; import tech.minediamond.vortex.service.search.EverythingService; import tech.minediamond.vortex.service.ui.StageProvider; @@ -145,6 +146,7 @@ public void stop() throws Exception { log.info("正在保存和清理资源..."); runSafely("保存配置文件",()-> injector.getInstance(AppConfigService.class).save()); + runSafely("保存数据",()-> injector.getInstance(DataService.class).save()); runSafely("注销JNativeHook", GlobalScreen::unregisterNativeHook); runSafely("注销FXTrayIcon",()-> trayMenuService.closeTrayMenu()); runSafely("退出Everything",()-> injector.getInstance(EverythingService.class).stopEverythingInstance()); diff --git a/src/main/java/tech/minediamond/vortex/config/AppModule.java b/src/main/java/tech/minediamond/vortex/config/AppModule.java index c2b7f13..71f5c11 100644 --- a/src/main/java/tech/minediamond/vortex/config/AppModule.java +++ b/src/main/java/tech/minediamond/vortex/config/AppModule.java @@ -23,10 +23,13 @@ import com.google.inject.Scopes; import com.google.inject.assistedinject.FactoryModuleBuilder; import tech.minediamond.vortex.model.appConfig.AppConfig; +import tech.minediamond.vortex.model.appConfig.MainPageData; import tech.minediamond.vortex.service.appConfig.AppConfigProvider; import tech.minediamond.vortex.service.appConfig.AppConfigService; import tech.minediamond.vortex.service.autoStart.MockAutoStartService; import tech.minediamond.vortex.service.autoStart.WindowsAutoStartService; +import tech.minediamond.vortex.service.data.DataProvider; +import tech.minediamond.vortex.service.data.DataService; import tech.minediamond.vortex.service.search.SearchService; import tech.minediamond.vortex.service.ui.ShowStageListenerFactory; import tech.minediamond.vortex.service.autoStart.IAutoStartService; @@ -47,6 +50,7 @@ public class AppModule extends AbstractModule { @Override protected void configure() { bind(AppConfig.class).toProvider(AppConfigProvider.class).in(Scopes.SINGLETON); + bind(MainPageData.class).toProvider(DataProvider.class).in(Scopes.SINGLETON); bind(AppConfigProvider.class).asEagerSingleton(); bind(AppConfigService.class).in(Scopes.SINGLETON); bind(StageProvider.class).in(Scopes.SINGLETON); @@ -54,6 +58,7 @@ protected void configure() { bind(I18nService.class); bind(EverythingService.class).asEagerSingleton(); bind(GlobalUncaughtExceptionHandlerService.class).in(Scopes.SINGLETON); + bind(DataService.class); bind(MainWindow.class); diff --git a/src/main/java/tech/minediamond/vortex/model/appConfig/MainPageData.java b/src/main/java/tech/minediamond/vortex/model/appConfig/MainPageData.java index b77213a..4d98a2a 100644 --- a/src/main/java/tech/minediamond/vortex/model/appConfig/MainPageData.java +++ b/src/main/java/tech/minediamond/vortex/model/appConfig/MainPageData.java @@ -19,15 +19,21 @@ package tech.minediamond.vortex.model.appConfig; +import javafx.beans.property.SimpleMapProperty; +import javafx.beans.property.SimpleObjectProperty; +import javafx.beans.value.ObservableObjectValue; +import javafx.collections.ObservableMap; import lombok.Getter; import lombok.Setter; +import tech.minediamond.vortex.model.data.DirectoryOrganize; +import tech.minediamond.vortex.model.fileData.FileData; import tech.minediamond.vortex.model.program.ProgramData; import java.util.ArrayList; @Getter -@Setter public class MainPageData { - //存放全局的应用信息数据 - public static ArrayList programData = new ArrayList<>(); + ObservableMap programDataObservableMap = new SimpleMapProperty<>(); + ObservableMap fileDataObservableMap = new SimpleMapProperty<>(); + ObservableObjectValue directoryOrganizeSimpleObjectProperty = new SimpleObjectProperty<>(); } diff --git a/src/main/java/tech/minediamond/vortex/model/data/DirectoryOrganize.java b/src/main/java/tech/minediamond/vortex/model/data/DirectoryOrganize.java new file mode 100644 index 0000000..e8a2733 --- /dev/null +++ b/src/main/java/tech/minediamond/vortex/model/data/DirectoryOrganize.java @@ -0,0 +1,24 @@ +/* + * Vortex + * Copyright (C) 2025 Mine-diamond + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package tech.minediamond.vortex.model.data; + +public interface DirectoryOrganize { + +} diff --git a/src/main/java/tech/minediamond/vortex/model/data/PageDirectory.java b/src/main/java/tech/minediamond/vortex/model/data/PageDirectory.java index aed820b..85e8a02 100644 --- a/src/main/java/tech/minediamond/vortex/model/data/PageDirectory.java +++ b/src/main/java/tech/minediamond/vortex/model/data/PageDirectory.java @@ -19,9 +19,14 @@ package tech.minediamond.vortex.model.data; -public class PageDirectory { +import java.util.ArrayList; +import java.util.List; + +public class PageDirectory implements DirectoryOrganize{ public String name; public String type; - + PosData posData = new PosData(); + + List directoryOrganizeList = new ArrayList<>(); } diff --git a/src/main/java/tech/minediamond/vortex/model/data/PosData.java b/src/main/java/tech/minediamond/vortex/model/data/PosData.java index 7f97087..4f5f019 100644 --- a/src/main/java/tech/minediamond/vortex/model/data/PosData.java +++ b/src/main/java/tech/minediamond/vortex/model/data/PosData.java @@ -19,6 +19,9 @@ package tech.minediamond.vortex.model.data; -public class PosData { - +public class PosData implements DirectoryOrganize{ + String resourceType; + String source; + int[] pos = new int[2]; + String posType; } diff --git a/src/main/java/tech/minediamond/vortex/service/data/DataProvider.java b/src/main/java/tech/minediamond/vortex/service/data/DataProvider.java new file mode 100644 index 0000000..d9e1608 --- /dev/null +++ b/src/main/java/tech/minediamond/vortex/service/data/DataProvider.java @@ -0,0 +1,49 @@ +/* + * Vortex + * Copyright (C) 2025 Mine-diamond + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package tech.minediamond.vortex.service.data; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Provider; +import lombok.extern.slf4j.Slf4j; +import tech.minediamond.vortex.model.appConfig.AppConfig; +import tech.minediamond.vortex.model.appConfig.MainPageData; + +import java.io.File; +import java.io.IOException; + +@Slf4j +public class DataProvider implements Provider { + + private static final File CONFIG_FILE = new File("mainPageData.json"); + private static final ObjectMapper MAPPER = new ObjectMapper(); + + @Override + public MainPageData get() { + log.info("正在加载data"); + try { + return CONFIG_FILE.exists() + ? MAPPER.readValue(CONFIG_FILE, MainPageData.class) + : new MainPageData(); + } catch (IOException e) { + log.error("data读取失败,使用默认值: {}", e.getMessage()); + return new MainPageData(); + } + } +} diff --git a/src/main/java/tech/minediamond/vortex/service/data/DataService.java b/src/main/java/tech/minediamond/vortex/service/data/DataService.java new file mode 100644 index 0000000..ca8a05f --- /dev/null +++ b/src/main/java/tech/minediamond/vortex/service/data/DataService.java @@ -0,0 +1,52 @@ +/* + * Vortex + * Copyright (C) 2025 Mine-diamond + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package tech.minediamond.vortex.service.data; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Inject; +import lombok.extern.slf4j.Slf4j; +import tech.minediamond.vortex.model.appConfig.MainPageData; + +import java.io.File; +import java.io.IOException; + +@Slf4j +public class DataService { + + private static final File CONFIG_FILE = new File("mainPageData.json"); + private static final ObjectMapper MAPPER = new ObjectMapper(); + + private final MainPageData mainPageData; + + @Inject + public DataService(MainPageData mainPageData) { + this.mainPageData = mainPageData; + } + + public void save() { + try { + MAPPER.writeValue(CONFIG_FILE, mainPageData); + log.info("保存data成功"); + } catch (IOException e) { + log.error("保存data失败: {}", e.getMessage()); + } + } + +} diff --git a/src/main/java/tech/minediamond/vortex/service/program/FindApplicationsService.java b/src/main/java/tech/minediamond/vortex/service/program/FindApplicationsService.java index 9307f7a..b55f178 100644 --- a/src/main/java/tech/minediamond/vortex/service/program/FindApplicationsService.java +++ b/src/main/java/tech/minediamond/vortex/service/program/FindApplicationsService.java @@ -156,7 +156,7 @@ public void getInstalledPrograms() throws IOException, InterruptedException { } } - MainPageData.programData.addAll(programs); + //MainPageData.programData.addAll(programs); LocalTime time3 = LocalTime.now(); log.info("数据处理时间:{}ms", Duration.between(time2, time3).toMillis()); @@ -166,7 +166,7 @@ public void getInstalledPrograms() throws IOException, InterruptedException { public static void main(String[] args) throws IOException, InterruptedException, SQLException { LocalTime start = LocalTime.now(); new FindApplicationsService().getInstalledPrograms(); - MainPageData.programData.forEach(System.out::println); + //MainPageData.programData.forEach(System.out::println); LocalTime end = LocalTime.now(); log.info("程序运行总时间: {}ms", Duration.between(start, end).toMillis()); } diff --git a/src/main/java/tech/minediamond/vortex/ui/component/IconGrid.java b/src/main/java/tech/minediamond/vortex/ui/component/IconGrid.java index f41b1ba..0f9bd42 100644 --- a/src/main/java/tech/minediamond/vortex/ui/component/IconGrid.java +++ b/src/main/java/tech/minediamond/vortex/ui/component/IconGrid.java @@ -27,12 +27,15 @@ import javafx.scene.layout.GridPane; import javafx.scene.layout.RowConstraints; import javafx.scene.layout.StackPane; +import tech.minediamond.vortex.model.appConfig.MainPageData; public class IconGrid extends Control { - @Inject - public IconGrid() { + private final MainPageData mainPageData; + @Inject + public IconGrid(MainPageData mainPageData) { + this.mainPageData = mainPageData; } @Override @@ -54,7 +57,7 @@ protected Skin(IconGrid control) { GridPane gridPane = new GridPane(); gridPane.setGridLinesVisible(true); - gridPane.setPadding(new Insets(20, 20, 20, 20)); + gridPane.setPadding(new Insets(20, 20, 0, 0)); gridPane.setPrefSize(1030,560); for (int i = 0; i < 12; i++) { diff --git a/src/main/java/tech/minediamond/vortex/ui/controller/MainPanel.java b/src/main/java/tech/minediamond/vortex/ui/controller/MainPanel.java index d898e42..8b28d27 100644 --- a/src/main/java/tech/minediamond/vortex/ui/controller/MainPanel.java +++ b/src/main/java/tech/minediamond/vortex/ui/controller/MainPanel.java @@ -22,17 +22,24 @@ import com.google.inject.Inject; import com.google.inject.Singleton; import javafx.fxml.FXML; -import javafx.scene.layout.GridPane; +import javafx.scene.layout.StackPane; +import tech.minediamond.vortex.ui.component.IconGrid; @Singleton public class MainPanel { @FXML - public GridPane mainGrid; + public StackPane mainPanelStackPane; + + private final IconGrid iconGrid; @Inject - public MainPanel() { + public MainPanel(IconGrid iconGrid) { + this.iconGrid = iconGrid; + } + public void initialize() { + mainPanelStackPane.getChildren().add(iconGrid); } } diff --git a/src/main/java/tech/minediamond/vortex/util/LaunchProgramUtil.java b/src/main/java/tech/minediamond/vortex/util/LaunchProgramUtil.java index af0b52a..bdb7274 100644 --- a/src/main/java/tech/minediamond/vortex/util/LaunchProgramUtil.java +++ b/src/main/java/tech/minediamond/vortex/util/LaunchProgramUtil.java @@ -34,21 +34,21 @@ public class LaunchProgramUtil { private static final String UWP_COMMAND_PREFIX = "shell:AppsFolder\\"; private static final String EXPLORER_EXECUTABLE = "explorer.exe"; - public static ProgramData getProgramInfoByID(String id) throws IOException { - ProgramData programData = new ProgramData(); - boolean found = false; - for(ProgramData info : MainPageData.programData) { - if(info.getId().equals(id)) { - programData = info; - found = true; - } - } - if(found) { - return programData; - }else { - return null; - } - } +// public static ProgramData getProgramInfoByID(String id) throws IOException { +// ProgramData programData = new ProgramData(); +// boolean found = false; +// for(ProgramData info : MainPageData.programData) { +// if(info.getId().equals(id)) { +// programData = info; +// found = true; +// } +// } +// if(found) { +// return programData; +// }else { +// return null; +// } +// } public static boolean openApplication(ProgramData programData) { diff --git a/src/main/resources/tech/minediamond/vortex/ui/mainPanel.fxml b/src/main/resources/tech/minediamond/vortex/ui/mainPanel.fxml index 735dba3..be3128d 100644 --- a/src/main/resources/tech/minediamond/vortex/ui/mainPanel.fxml +++ b/src/main/resources/tech/minediamond/vortex/ui/mainPanel.fxml @@ -24,8 +24,8 @@ + fx:controller="tech.minediamond.vortex.ui.controller.MainPanel" + fx:id="mainPanelStackPane"> -