Selaa lähdekoodia

Project1.exe Project2.exe multiCamera.exe 绝对路径执行

Michael Wang 4 vuotta sitten
vanhempi
commit
5057e2df1f
1 muutettua tiedostoa jossa 21 lisäystä ja 0 poistoa
  1. 21 0
      src/utils/nativeExe.js

+ 21 - 0
src/utils/nativeExe.js

@@ -32,7 +32,28 @@ export default function async(exeName, cb) {
         data,
         stderr: JSON.stringify(stderr),
         stderrConverted: JSON.stringify(stderrConverted),
+        absPath: exeName.includes(":"),
       });
+      // 如果相对路径没找到,则通过绝对路径来执行
+      if (!exeName.includes(":")) {
+        const fs = window.nodeRequire("electron").remote.require("fs");
+
+        const path = window.nodeRequire("electron").remote.require("path");
+
+        const [exePath, exeParams] = exeName.split(" ");
+        const absPath = path.join(
+          window.nodeRequire("electron").remote.app.getAppPath(),
+          "../../",
+          exePath
+        );
+        if (fs.existsSync(absPath)) {
+          try {
+            await async([absPath, exeParams].join(" ").trim());
+          } catch (error) {
+            console.log("second try error", absPath);
+          }
+        }
+      }
       await new Promise((resolve2) => setTimeout(() => resolve2(), 1000));
       await cb();
       resolve();