|
|
@@ -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;
|
|
|
-
|