|
@@ -3,6 +3,9 @@ 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 process from "process";
|
|
|
+
|
|
|
const isDev = process.env.NODE_ENV === "development";
|
|
|
let win: any = null;
|
|
|
let loadWin: any = null;
|
|
@@ -116,7 +119,7 @@ function createLoadWin() {
|
|
|
// createLoadWin();
|
|
|
// });
|
|
|
|
|
|
-ipcMain.on("change-win-size", (event, args) => {
|
|
|
+ipcMain.on("change-win-size", (event, args: string) => {
|
|
|
const { width, height } = screen.getPrimaryDisplay().workAreaSize;
|
|
|
let w = args === "big" ? width : 840;
|
|
|
let h = args === "big" ? height : 500;
|
|
@@ -130,6 +133,63 @@ ipcMain.on("window-min", () => {
|
|
|
win.minimize();
|
|
|
});
|
|
|
|
|
|
+function startExe(exePath: string) {
|
|
|
+ const childProcess = child_process.spawn(exePath);
|
|
|
+
|
|
|
+ childProcess.on("close", (code: any) => {
|
|
|
+ console.log("close---- code:", code);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// ipcMain.on("startExe", (event, args: string) => {
|
|
|
+// startExe(args);
|
|
|
+// });
|
|
|
+
|
|
|
+// ipcMain.handle("checkProcessExist", async (event, processName) => {
|
|
|
+// try {
|
|
|
+// const processExists = await checkProcessExist(processName);
|
|
|
+// if (processExists) {
|
|
|
+// dialog.showErrorBox("tip", `${processName}已启动`);
|
|
|
+// } else {
|
|
|
+// const exePath = path.join(
|
|
|
+// process.env.PORTABLE_EXECUTABLE_DIR as string,
|
|
|
+// "text.exe"
|
|
|
+// );
|
|
|
+// const fileExists = fs.existsSync(exePath);
|
|
|
+// if (fileExists) {
|
|
|
+// startExe(exePath);
|
|
|
+// } else {
|
|
|
+// dialog.showErrorBox("tip", ".exe not exist!");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return processExists;
|
|
|
+// } catch (error) {
|
|
|
+// console.error(error);
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+// });
|
|
|
+
|
|
|
+// function checkProcessExist(processName: string) {
|
|
|
+// return new Promise((resolve, reject) => {
|
|
|
+// const command = process.platform === "win32" ? "tasklist" : "ps aux";
|
|
|
+// const childProcess = child_process.spawn(command);
|
|
|
+
|
|
|
+// childProcess.stdout.on("data", (data: any) => {
|
|
|
+// if (data.toString().indexOf(processName) !== -1) {
|
|
|
+// resolve(true);
|
|
|
+// }
|
|
|
+// });
|
|
|
+
|
|
|
+// childProcess.stderr.on("data", (data: any) => {
|
|
|
+// reject(data.toString());
|
|
|
+// });
|
|
|
+
|
|
|
+// childProcess.on("close", (code: any) => {
|
|
|
+// resolve(false);
|
|
|
+// });
|
|
|
+// });
|
|
|
+// }
|
|
|
+
|
|
|
app.on("ready", async () => {
|
|
|
if (isDev) {
|
|
|
try {
|