[feat-578] open steam common folder for selecting a proton folder

This commit is contained in:
silentrald
2024-10-23 10:49:46 +08:00
parent 3812ea18e4
commit 77987181de
5 changed files with 30 additions and 6 deletions
+16 -2
View File
@@ -1,9 +1,10 @@
import { shell, dialog, app, BrowserWindow } from "electron";
import { shell, dialog, app, BrowserWindow, OpenDialogOptions } from "electron";
import { NotificationService } from "../services/notification.service";
import { IpcService } from "../services/ipc.service";
import { from, of } from "rxjs";
import { readFileSync } from "fs-extra";
import log from "electron-log";
import path from "path";
// TODO IMPROVE WINDOW CONTROL BY USING WINDOW SERVICE
@@ -19,7 +20,20 @@ ipc.on("open-dialog", (args, reply) => {
})
ipc.on("choose-folder", (args, reply) => {
reply(from(dialog.showOpenDialog({ properties: ["openDirectory"], defaultPath: args ?? "" })));
const options: OpenDialogOptions = {
properties: ["openDirectory"],
defaultPath: args?.defaultPath ?? ""
};
if (args?.showHidden) {
options.properties.push("showHiddenFiles");
}
if (args?.parent) {
options.defaultPath = path.join(app.getPath(args.parent), options.defaultPath);
}
reply(from(dialog.showOpenDialog(options)));
});
ipc.on("choose-file", async (args, reply) => {