Jelajahi Sumber

Revert "mod:打开相机方式 调整"

This reverts commit ab7f9f7b43d39f35f0ebcd33510efdae19064b7a.
panqiuyao 7 bulan lalu
induk
melakukan
5397c7f8b6
1 mengubah file dengan 18 tambahan dan 15 penghapusan
  1. 18 15
      electron/controller/camera.js

+ 18 - 15
electron/controller/camera.js

@@ -69,7 +69,7 @@ async function checkCameraControlCmdExists() {
 
 
 async function openCameraControlCmd() {
-  return new Promise(async (resolve, reject) => {
+ return  new Promise(async (resolve, reject) => {
     try {
       // 获取 digiCamControl 文件夹路径
       const digiCamControlPath = config.digiCamControl;
@@ -79,19 +79,23 @@ async function openCameraControlCmd() {
 
       // 检查文件是否存在
       await fs.promises.access(exePath, fs.constants.F_OK);
-
       try {
-        // 替换为 execFile
-        const { execFile } = require('child_process');
-        execFile(exePath, (error, stdout, stderr) => {
-          if (error) {
-            console.error('执行 CameraControl.exe 出错:', error);
-            reject(false);
-            return;
-          }
-          console.log('CameraControl.exe 输出:', stdout);
-          resolve(true);
-        });
+
+          const child = spawn(exePath);
+
+          child.stdout.on('data', (data) => {
+
+            resolve(true)
+          });
+
+          child.on('close', (code) => {
+            if (code === 0) {
+              reject(false)
+            }
+          });
+
+
+
       } catch (error) {
         console.error('error CameraControlCmd.exe:', error);
         throw error;
@@ -102,7 +106,7 @@ async function openCameraControlCmd() {
       console.error('无法找到或运行 CameraControlCmd.exe:', error);
       throw error;
     }
-  });
+  })
 }
 
 function closeCameraControlTips() {
@@ -236,4 +240,3 @@ class CameraController extends Controller {
 
 CameraController.toString = () => '[class CameraController]';
 module.exports = CameraController;
-