Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/tech/minediamond/vortex/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/tech/minediamond/vortex/config/AppModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -47,13 +50,15 @@ 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);
bind(AutoOperateService.class).in(Scopes.SINGLETON);
bind(I18nService.class);
bind(EverythingService.class).asEagerSingleton();
bind(GlobalUncaughtExceptionHandlerService.class).in(Scopes.SINGLETON);
bind(DataService.class);


bind(MainWindow.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String,ProgramData> programDataObservableMap = new SimpleMapProperty<>();
ObservableMap<String,FileData> fileDataObservableMap = new SimpleMapProperty<>();
ObservableObjectValue<DirectoryOrganize> directoryOrganizeSimpleObjectProperty = new SimpleObjectProperty<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<ProgramInfo> programInfos = new ArrayList<>();
public class MainResourceData {
public static ArrayList<ProgramData> programData = new ArrayList<>();
public static ArrayList<FileData> fileData = new ArrayList<>();
}
Original file line number Diff line number Diff line change
@@ -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 {

}
Original file line number Diff line number Diff line change
@@ -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<DirectoryOrganize> directoryOrganizeList = new ArrayList<>();
}
27 changes: 27 additions & 0 deletions src/main/java/tech/minediamond/vortex/model/data/PosData.java
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@Setter
@ToString
@EqualsAndHashCode
public class ProgramInfo {
public class ProgramData {

private String baseName;

Expand All @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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<MainPageData> {

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();
}
}
}
Original file line number Diff line number Diff line change
@@ -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());
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -137,26 +137,26 @@ public void getInstalledPrograms() throws IOException, InterruptedException {
log.info("powershell执行时间:{}ms", Duration.between(time, time2).toMillis());

ObjectMapper mapper = new ObjectMapper();
List<ProgramInfo> programs = mapper.readValue(jsonOutput, new TypeReference<List<ProgramInfo>>() {});
List<ProgramData> programs = mapper.readValue(jsonOutput, new TypeReference<List<ProgramData>>() {});

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());
Expand All @@ -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());
}
Expand Down
Loading
Loading