Explorar el Código

mod:选择dig软件目录 改成localstore

panqiuyao hace 8 meses
padre
commit
c15474965e

+ 1 - 2
electron/config/app.config.json

@@ -1,4 +1,3 @@
 {
-  "digiCamControl": "C:\\Program Files (x86)\\digiCamControl",
   "pyapp": "127.0.0.1"
-}
+}

+ 19 - 32
electron/controller/camera.js

@@ -8,31 +8,10 @@ const { liveShow, liveHide, setParams, capture, getParams,CMD,captureLive,closeO
 
 const { dialog } = require('electron'); // 引入 electron 的 dialog 模块
 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 {
-    // 获取 digiCamControl 文件夹路径
-    const digiCamControlPath = config.digiCamControl;
 
     // 拼接 CameraControlCmd.exe 的完整路径
     const exePath = path.join(digiCamControlPath, 'CameraControl.exe');
@@ -52,15 +31,24 @@ async function checkCameraControlCmdExists() {
       if (!canceled && filePaths.length > 0) {
         const selectedPath = filePaths[0];
         // 更新 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 {
         console.error('用户未选择文件夹');
-        return false;
+        return {
+          status:-1,
+          msg:"无法找到或运行 CameraControlCmd.exe",
+        }
       }
     }
-    const res = await openCameraControlCmd();
+    const res = await openCameraControlCmd(digiCamControlPath);
     return res;
   } catch (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) => {
     try {
       // 获取 digiCamControl 文件夹路径
-      const digiCamControlPath = config.digiCamControl;
 
       // 拼接 CameraControlCmd.exe 的完整路径
       const exePath = path.join(digiCamControlPath, 'CameraControl.exe');
@@ -138,13 +125,13 @@ class CameraController extends Controller {
     super(ctx);
   }
 
-  async connect() {
+  async connect(digiCamControlPath) {
     try {
       await getParams('iso').catch(e=>{
         isOPen = false;
       })
       if(!isOPen){
-        await checkCameraControlCmdExists()
+        await checkCameraControlCmdExists(digiCamControlPath)
         await  CMD('All_Minimize')
         await closeCameraControlTips()
         isOPen = true

+ 12 - 4
frontend/src/stores/modules/check.ts

@@ -4,6 +4,7 @@ import socket from "./socket";
 import icpList from "../../utils/ipc";
 import client from "./client";
 import {ElMessage} from "element-plus";
+import  configInfo  from '@/stores/modules/config';
 const socketStore = socket();
 const clientStore = client();
 
@@ -86,11 +87,19 @@ export const checkInfo = defineStore('checkInfo', () => {
         return null;
     });
 
+    const configInfoStore = configInfo();
     const checkcamControl = async ()=>{
 
 
               clientStore.ipc.removeAllListeners(icpList.camera.connect);
-              clientStore.ipc.send(icpList.camera.connect);
+              clientStore.ipc.send(icpList.camera.connect,configInfoStore.digiCamControlPath);
+              clientStore.ipc.on(icpList.camera.digiCamControlPath, async (event, result) => {
+                clientStore.ipc.removeAllListeners(icpList.camera.digiCamControlPath);
+                if(result.code === 0 && result.data){
+                    configInfoStore.updateDigiCamControlPath(result.data)
+                }
+
+              })
               clientStore.ipc.on(icpList.camera.connect, async (event, result) => {
 
 
@@ -134,7 +143,6 @@ export const checkInfo = defineStore('checkInfo', () => {
                 console.log(result);
                 if (result && checkTime.value > 0) {
                     if(deviceName === 'mcu'){
-                        console.log(result);
                         if(result.status === 2 ){
                             if(!mcu.isInitSend){
                                 socketStore.sendMessage({
@@ -157,14 +165,14 @@ export const checkInfo = defineStore('checkInfo', () => {
                             }
                         }
                         if([-1,0].includes(result.status)){
-                            if(result.status === -1 ){
+                   /*         if(result.status === -1 ){
                                 if(mcuErrorCount.value  === 0){
                                     mcuErrorCount.value++;
                                     return;
                                 }else{
                                     mcuErrorCount.value = 0
                                 }
-                            }
+                            }*/
                             devices[deviceName].status = result.status;
                             devices[deviceName].msg = result.msg;
                         }

+ 21 - 0
frontend/src/stores/modules/config.ts

@@ -0,0 +1,21 @@
+import { defineStore } from 'pinia';
+import { ref, computed } from 'vue';
+
+
+export const configInfo = defineStore('config',()=>{
+  const digiCamControlPath = ref("C:\\Program Files (x86)\\digiCamControl")
+  const updateDigiCamControlPath = (data:string)=>{
+    console.log("updateDigiCamControlPath",data)
+    digiCamControlPath.value = data
+    console.log(digiCamControlPath.value)
+  }
+  return {
+    digiCamControlPath,
+    updateDigiCamControlPath
+  }
+},{
+  persist:true,
+})
+
+
+export default configInfo;

+ 2 - 1
frontend/src/utils/ipc.ts

@@ -4,7 +4,8 @@ const icpList = {
         PreviewShow: 'controller.camera.liveShow',
         PreviewHide: 'controller.camera.liveHide',
         setParams:"controller.camera.setParams",
-        takePictures:"controller.camera.takePictures"
+        takePictures:"controller.camera.takePictures",
+        digiCamControlPath:"controller.camera.digiCamControlPath",
     },
     socket:{
         connect: 'controller.socket.connect',

+ 16 - 0
frontend/src/views/Home/index.vue

@@ -43,6 +43,7 @@
 
     <el-button type="info"  @click="openSeeting">打开设置</el-button>
     <el-button type="info"  @click="openTplSeeting">打开主图和详情设置</el-button>
+    <el-button type="info"  @click="opendigiCamControl">打开digiCamControl</el-button>
 
 
 
@@ -345,6 +346,21 @@ function openTplSeeting(){
 }
 
 
+import  configInfo  from '@/stores/modules/config';
+const configInfoStore = configInfo();
+const  opendigiCamControl = ()=>{
+
+  clientStore.ipc.removeAllListeners(icpList.camera.connect);
+  clientStore.ipc.send(icpList.camera.connect,configInfoStore.digiCamControlPath);
+  clientStore.ipc.on(icpList.camera.digiCamControlPath, async (event, result) => {
+    clientStore.ipc.removeAllListeners(icpList.camera.digiCamControlPath);
+    if(result.code === 0 && result.data){
+      configInfoStore.updateDigiCamControlPath(result.data)
+    }
+
+  })
+}
+
 
 </script>
 

+ 2 - 2
frontend/src/views/Photography/check.vue

@@ -14,10 +14,10 @@
           <div class="left-panel flex-col justify-between">
             <div class="tips-container flex-row" v-if="show">
                 <spanc  v-if="isSetting" class="tips-tex">
-                  请在圆盘上摆上鞋子(注意左右脚),要求鞋外侧朝向拍照机,鞋子中轴线和红外线对齐,如果光亮不够,可以打开光源。
+                  请在圆盘上摆上鞋子(注意左右脚),要求鞋外侧朝向拍照机,鞋子中轴线和红外线对齐,如果光亮不够,可以打开环境光源,关闭闪光灯
                 </spanc>
                 <span v-else class="tips-tex">
-                  请在圆盘上摆上鞋子(注意左右脚),要求鞋外侧朝向拍照机,鞋子中轴线和红外线对齐,可以打开光源。
+                  请在圆盘上摆上鞋子(注意左右脚),要求鞋外侧朝向拍照机,鞋子中轴线和红外线对齐,如果光亮不够,可以打开环境光源,关闭闪光灯
                 </span>
             </div>
             <div class="camera-preview  flex col center ">