|
@@ -3,7 +3,7 @@ import fs from "fs";
|
|
|
import { app, BrowserWindow, Menu, screen, dialog, ipcMain } from "electron";
|
|
|
import installExtension, { VUEJS3_DEVTOOLS } from "electron-devtools-installer";
|
|
|
|
|
|
-import child_process from "child_process";
|
|
|
+import { exec } from "child_process";
|
|
|
import process from "process";
|
|
|
|
|
|
const isDev = process.env.NODE_ENV === "development";
|
|
@@ -32,37 +32,6 @@ function createWin() {
|
|
|
win.loadURL(`http://localhost:8090`);
|
|
|
} else {
|
|
|
win.loadFile(path.resolve(__dirname, "index.html"));
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
win.webContents.once("dom-ready", () => {
|
|
@@ -134,61 +103,21 @@ ipcMain.on("window-min", () => {
|
|
|
});
|
|
|
|
|
|
function startExe(exePath: string) {
|
|
|
- const childProcess = child_process.spawn(exePath);
|
|
|
-
|
|
|
- childProcess.on("close", (code: any) => {
|
|
|
- console.log("close---- code:", code);
|
|
|
- });
|
|
|
+ console.log("主进程接收到的exe路径:", exePath);
|
|
|
+ let checkPath = exePath.includes(".exe ")
|
|
|
+ ? exePath.split(".exe ")[0] + ".exe"
|
|
|
+ : exePath;
|
|
|
+ const fileExists = fs.existsSync(checkPath);
|
|
|
+ if (fileExists) {
|
|
|
+ exec(exePath);
|
|
|
+ } else {
|
|
|
+ dialog.showErrorBox("tip", `${checkPath}不存在!`);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ipcMain.on("startExe", (event, args: string) => {
|
|
|
+ startExe(args);
|
|
|
+});
|
|
|
|
|
|
app.on("ready", async () => {
|
|
|
if (isDev) {
|