|
@@ -8,31 +8,10 @@ const { liveShow, liveHide, setParams, capture, getParams,CMD,captureLive,closeO
|
|
|
|
|
|
|
|
const { dialog } = require('electron'); // 引入 electron 的 dialog 模块
|
|
const { dialog } = require('electron'); // 引入 electron 的 dialog 模块
|
|
|
const { windowManager } = require('node-window-manager');
|
|
const { windowManager } = require('node-window-manager');
|
|
|
-// 检查并读取配置文件
|
|
|
|
|
-function readConfigFile(configPath) {
|
|
|
|
|
- try {
|
|
|
|
|
- // 检查文件是否存在
|
|
|
|
|
- if (!fs.existsSync(configPath)) {
|
|
|
|
|
- // 创建默认配置文件
|
|
|
|
|
- const defaultConfig = {};
|
|
|
|
|
- fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
|
|
|
|
|
- return defaultConfig;
|
|
|
|
|
- }
|
|
|
|
|
- // 读取配置文件
|
|
|
|
|
- return JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- console.error('读取配置文件时出错:', error);
|
|
|
|
|
- throw error;
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-const configPath = path.join(__dirname, '..', 'config', 'app.config.json');
|
|
|
|
|
-const config = readConfigFile(configPath);
|
|
|
|
|
|
|
+const CoreWindow = require("ee-core/electron/window");
|
|
|
|
|
|
|
|
-async function checkCameraControlCmdExists() {
|
|
|
|
|
|
|
+async function checkCameraControlCmdExists(digiCamControlPath) {
|
|
|
try {
|
|
try {
|
|
|
- // 获取 digiCamControl 文件夹路径
|
|
|
|
|
- const digiCamControlPath = config.digiCamControl;
|
|
|
|
|
|
|
|
|
|
// 拼接 CameraControlCmd.exe 的完整路径
|
|
// 拼接 CameraControlCmd.exe 的完整路径
|
|
|
const exePath = path.join(digiCamControlPath, 'CameraControl.exe');
|
|
const exePath = path.join(digiCamControlPath, 'CameraControl.exe');
|
|
@@ -52,15 +31,24 @@ async function checkCameraControlCmdExists() {
|
|
|
if (!canceled && filePaths.length > 0) {
|
|
if (!canceled && filePaths.length > 0) {
|
|
|
const selectedPath = filePaths[0];
|
|
const selectedPath = filePaths[0];
|
|
|
// 更新 app.config.json 中的 digiCamControl 值
|
|
// 更新 app.config.json 中的 digiCamControl 值
|
|
|
- config.digiCamControl = selectedPath;
|
|
|
|
|
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
|
|
|
- return true; // 重新检查文件是否存在
|
|
|
|
|
|
|
+ // config.digiCamControl = selectedPath;
|
|
|
|
|
+ // fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
|
|
|
+ digiCamControlPath = selectedPath
|
|
|
|
|
+ const win = CoreWindow.getMainWindow()
|
|
|
|
|
+ win.webContents.send('controller.camera.digiCamControlPath', {
|
|
|
|
|
+ code:0,
|
|
|
|
|
+ data:selectedPath,
|
|
|
|
|
+ });
|
|
|
|
|
+ // return true; // 重新检查文件是否存在
|
|
|
} else {
|
|
} else {
|
|
|
console.error('用户未选择文件夹');
|
|
console.error('用户未选择文件夹');
|
|
|
- return false;
|
|
|
|
|
|
|
+ return {
|
|
|
|
|
+ status:-1,
|
|
|
|
|
+ msg:"无法找到或运行 CameraControlCmd.exe",
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- const res = await openCameraControlCmd();
|
|
|
|
|
|
|
+ const res = await openCameraControlCmd(digiCamControlPath);
|
|
|
return res;
|
|
return res;
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error('检查 CameraControlCmd.exe 是否存在时出错:', error);
|
|
console.error('检查 CameraControlCmd.exe 是否存在时出错:', error);
|
|
@@ -69,11 +57,10 @@ async function checkCameraControlCmdExists() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-async function openCameraControlCmd() {
|
|
|
|
|
|
|
+async function openCameraControlCmd(digiCamControlPath) {
|
|
|
return new Promise(async (resolve, reject) => {
|
|
return new Promise(async (resolve, reject) => {
|
|
|
try {
|
|
try {
|
|
|
// 获取 digiCamControl 文件夹路径
|
|
// 获取 digiCamControl 文件夹路径
|
|
|
- const digiCamControlPath = config.digiCamControl;
|
|
|
|
|
|
|
|
|
|
// 拼接 CameraControlCmd.exe 的完整路径
|
|
// 拼接 CameraControlCmd.exe 的完整路径
|
|
|
const exePath = path.join(digiCamControlPath, 'CameraControl.exe');
|
|
const exePath = path.join(digiCamControlPath, 'CameraControl.exe');
|
|
@@ -138,13 +125,13 @@ class CameraController extends Controller {
|
|
|
super(ctx);
|
|
super(ctx);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- async connect() {
|
|
|
|
|
|
|
+ async connect(digiCamControlPath) {
|
|
|
try {
|
|
try {
|
|
|
await getParams('iso').catch(e=>{
|
|
await getParams('iso').catch(e=>{
|
|
|
isOPen = false;
|
|
isOPen = false;
|
|
|
})
|
|
})
|
|
|
if(!isOPen){
|
|
if(!isOPen){
|
|
|
- await checkCameraControlCmdExists()
|
|
|
|
|
|
|
+ await checkCameraControlCmdExists(digiCamControlPath)
|
|
|
await CMD('All_Minimize')
|
|
await CMD('All_Minimize')
|
|
|
await closeCameraControlTips()
|
|
await closeCameraControlTips()
|
|
|
isOPen = true
|
|
isOPen = true
|