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 new file mode 100644 index 0000000..4d98a2a --- /dev/null +++ b/src/main/java/tech/minediamond/vortex/model/appConfig/MainPageData.java @@ -0,0 +1,39 @@ +/* + * 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 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 +public class MainPageData { + ObservableMap programDataObservableMap = new SimpleMapProperty<>(); + ObservableMap fileDataObservableMap = new SimpleMapProperty<>(); + ObservableObjectValue directoryOrganizeSimpleObjectProperty = new SimpleObjectProperty<>(); +} diff --git a/src/main/java/tech/minediamond/vortex/model/appConfig/GlobalDataStore.java b/src/main/java/tech/minediamond/vortex/model/appConfig/MainResourceData.java similarity index 74% rename from src/main/java/tech/minediamond/vortex/model/appConfig/GlobalDataStore.java rename to src/main/java/tech/minediamond/vortex/model/appConfig/MainResourceData.java index 0acf7f6..234e224 100644 --- a/src/main/java/tech/minediamond/vortex/model/appConfig/GlobalDataStore.java +++ b/src/main/java/tech/minediamond/vortex/model/appConfig/MainResourceData.java @@ -19,15 +19,12 @@ package tech.minediamond.vortex.model.appConfig; -import lombok.Getter; -import lombok.Setter; -import tech.minediamond.vortex.model.program.ProgramInfo; +import tech.minediamond.vortex.model.fileData.FileData; +import tech.minediamond.vortex.model.program.ProgramData; import java.util.ArrayList; -@Getter -@Setter -public class GlobalDataStore { - //存放全局的应用信息数据 - public static ArrayList programInfos = new 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/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 new file mode 100644 index 0000000..85e8a02 --- /dev/null +++ b/src/main/java/tech/minediamond/vortex/model/data/PageDirectory.java @@ -0,0 +1,32 @@ +/* + * 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; + +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 new file mode 100644 index 0000000..4f5f019 --- /dev/null +++ b/src/main/java/tech/minediamond/vortex/model/data/PosData.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 PosData implements DirectoryOrganize{ + String resourceType; + String source; + int[] pos = new int[2]; + String posType; +} 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/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/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 6105c08..b55f178 100644 --- a/src/main/java/tech/minediamond/vortex/service/program/FindApplicationsService.java +++ b/src/main/java/tech/minediamond/vortex/service/program/FindApplicationsService.java @@ -24,8 +24,8 @@ 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.program.ProgramInfo; +import tech.minediamond.vortex.model.appConfig.MainPageData; +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); + //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.programInfos.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..0f9bd42 --- /dev/null +++ b/src/main/java/tech/minediamond/vortex/ui/component/IconGrid.java @@ -0,0 +1,80 @@ +/* + * 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; +import tech.minediamond.vortex.model.appConfig.MainPageData; + +public class IconGrid extends Control { + + private final MainPageData mainPageData; + + @Inject + public IconGrid(MainPageData mainPageData) { + this.mainPageData = mainPageData; + } + + @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, 0, 0)); + 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/ui/controller/MainPanel.java b/src/main/java/tech/minediamond/vortex/ui/controller/MainPanel.java new file mode 100644 index 0000000..8b28d27 --- /dev/null +++ b/src/main/java/tech/minediamond/vortex/ui/controller/MainPanel.java @@ -0,0 +1,45 @@ +/* + * 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.StackPane; +import tech.minediamond.vortex.ui.component.IconGrid; + +@Singleton +public class MainPanel { + + @FXML + public StackPane mainPanelStackPane; + + private final IconGrid iconGrid; + + @Inject + public MainPanel(IconGrid iconGrid) { + this.iconGrid = iconGrid; + } + + public void initialize() { + mainPanelStackPane.getChildren().add(iconGrid); + } + +} 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..495b0aa 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; @@ -126,8 +128,7 @@ public void initialize() { handleDragWindow(); initUIComponent(); - loadOrGetView(currentContentPanelProperty.get()); - mainToggleGroup.selectToggle(quickEditBtn); + currentContentPanelProperty.set(ContentPanel.MAIN_PANEL); } /** @@ -194,6 +195,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 +302,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/java/tech/minediamond/vortex/util/LaunchProgramUtil.java b/src/main/java/tech/minediamond/vortex/util/LaunchProgramUtil.java index b153533..bdb7274 100644 --- a/src/main/java/tech/minediamond/vortex/util/LaunchProgramUtil.java +++ b/src/main/java/tech/minediamond/vortex/util/LaunchProgramUtil.java @@ -20,8 +20,8 @@ package tech.minediamond.vortex.util; import lombok.extern.slf4j.Slf4j; -import tech.minediamond.vortex.model.appConfig.GlobalDataStore; -import tech.minediamond.vortex.model.program.ProgramInfo; +import tech.minediamond.vortex.model.appConfig.MainPageData; +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(); - boolean found = false; - for(ProgramInfo info : GlobalDataStore.programInfos) { - if(info.getId().equals(id)) { - programInfo = info; - found = true; - } - } - if(found) { - return programInfo; - }else { - return null; - } - } - - public static boolean openApplication(ProgramInfo programInfo) { +// 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) { 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/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..5647509 100644 --- a/src/main/resources/tech/minediamond/vortex/css/fluent-style.css +++ b/src/main/resources/tech/minediamond/vortex/css/fluent-style.css @@ -473,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 -> 特殊样式及覆盖 * =================================================================== */ @@ -494,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 a95e07c..dfecaf7 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..be3128d --- /dev/null +++ b/src/main/resources/tech/minediamond/vortex/ui/mainPanel.fxml @@ -0,0 +1,31 @@ + + + + + + + + + + +