Use openPath workaround on windows

Fixes #1700
This commit is contained in:
2024-02-21 19:05:28 -05:00
parent 7492e7eb11
commit 5f732bb5bf
7 changed files with 23 additions and 8 deletions
+3 -1
View File
@@ -1,6 +1,7 @@
import fs from "fs";
import path from "path";
import electron from "electron";
import {spawn} from "child_process";
import ReactDevTools from "./reactdevtools";
import * as IPCEvents from "common/constants/ipcevents";
@@ -97,7 +98,8 @@ export default class BetterDiscord {
electron.app.exit();
}
if (result.response === 1) {
electron.shell.openPath(path.join(dataPath, "plugins"));
if (process.platform === "win32") spawn("explorer.exe", [path.join(dataPath, "plugins")]);
else electron.shell.openPath(path.join(dataPath, "plugins"));
}
});
hasCrashed = false;
+8 -1
View File
@@ -1,4 +1,5 @@
import {ipcMain as ipc, BrowserWindow, app, dialog, systemPreferences} from "electron";
import {spawn} from "child_process";
import {ipcMain as ipc, BrowserWindow, app, dialog, systemPreferences, shell} from "electron";
import * as IPCEvents from "common/constants/ipcevents";
@@ -32,6 +33,11 @@ const getPath = (event, pathReq) => {
event.returnValue = returnPath;
};
const openPath = (event, path) => {
if (process.platform === "win32") spawn("explorer.exe", [path]);
else shell.openPath(path);
};
const relaunch = () => {
app.quit();
app.relaunch();
@@ -140,6 +146,7 @@ export default class IPCMain {
static registerEvents() {
try {
ipc.on(IPCEvents.GET_PATH, getPath);
ipc.on(IPCEvents.OPEN_PATH, openPath);
ipc.on(IPCEvents.RELAUNCH, relaunch);
ipc.on(IPCEvents.OPEN_DEVTOOLS, openDevTools);
ipc.on(IPCEvents.CLOSE_DEVTOOLS, closeDevTools);
+2 -1
View File
@@ -19,7 +19,8 @@ module.exports = (env, argv) => ({
rimraf: `require("rimraf")`,
yauzl: `require("yauzl")`,
mkdirp: `require("mkdirp")`,
module: `require("module")`
module: `require("module")`,
child_process: `require("child_process")`,
},
resolve: {
extensions: [".js"],