Browse Source

mod:检查

panqiuyao 8 months ago
parent
commit
19d098bbe8

+ 58 - 11
electron/api/camera.js

@@ -1,18 +1,54 @@
-const axios = require('axios')
+const axios = require('axios');
+const http = require('http');
+const { net } = require('electron');
 
-const service = axios.create()
-const baseUrl = 'http://localhost:5513/'
-const timeout = 60000
+//
+const baseURL = 'http://localhost:5513/';
+// ´´½¨ Axios ʵÀý
+const service = axios.create({
+  baseURL:baseURL,
+  timeout: 60000,
+});
 
 
+// ·â×° GET ·½·¨
+function get(config = { url: '' }) {
+  return service.get(config.url, {
+    insecureHTTPParser: true,
+    timeout: config.timeout || 60000,
+  });
+}
+
+
+async function fetchExampleData(url) {
+  return new Promise((resolve, reject) => {
+    const request = net.request({
+      method: 'GET',
+      url: baseURL+url
+    });
 
-function get(config = {
-  url: '',
-}) {
-  return service.get(baseUrl  + config.url, {
-    headers: config.headers || {},
-    timeout: config.timeout ||  timeout
-  })
+    request.on('response', (response) => {
+      let data = '';
+      response.on('data', (chunk) => {
+        data += chunk;
+      });
+      response.on('end', () => {
+        try {
+          resolve(data);
+        } catch (error) {
+          console.error('Error parsing data:', error);
+          reject(error);
+        }
+      });
+    });
+
+    request.on('error', (error) => {
+      console.error('Request error:', error);
+      reject(error);
+    });
+
+    request.end();
+  });
 }
 
 
@@ -33,7 +69,18 @@ module.exports = {
       url: '?CMD=LiveView_Capture'
     })
   },
+
+  CMD(cmd){
+    return get({
+      url: '?CMD='+cmd
+    })
+  },
+
+  getParams(params){
+    return  fetchExampleData(`?slc=get&param1=${params}`)
+  },
   setParams(params){
+
     return get({
       url: `?slc=set&param1=${params.key}&param2=${params.value}`
     })

+ 3 - 0
electron/config/app.config.json

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

+ 159 - 7
electron/controller/camera.js

@@ -1,24 +1,161 @@
 'use strict';
 
+const path = require('path');
+const fs = require('fs');
 const { Controller } = require('ee-core');
-const { liveShow,liveHide,setParams,capture }  = require('../api/camera')
+const { spawn } = require('child_process');
+const { liveShow, liveHide, setParams, capture, getParams,CMD } = require('../api/camera');
+const { dialog } = require('electron'); // 引入 electron 的 dialog 模块
+
+// 检查并读取配置文件
+function readConfigFile(configPath) {
+  try {
+    // 检查文件是否存在
+    if (!fs.existsSync(configPath)) {
+      // 创建默认配置文件
+      const defaultConfig = {
+        digiCamControl: ''
+      };
+      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);
+
+async function checkCameraControlCmdExists() {
+  try {
+    // 获取 digiCamControl 文件夹路径
+    const digiCamControlPath = config.digiCamControl;
+
+    // 拼接 CameraControlCmd.exe 的完整路径
+    const exePath = path.join(digiCamControlPath, 'CameraControl.exe');
+
+    // 检查文件是否存在
+    const exists = await fs.promises.access(exePath, fs.constants.F_OK)
+      .then(() => true)
+      .catch(() => false);
+
+    if (!exists) {
+      // 弹出文件夹选择对话框
+      const { canceled, filePaths } = await dialog.showOpenDialog({
+        title: '选择 digiCamControl 文件夹',
+        properties: ['openDirectory']
+      });
+
+      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; // 重新检查文件是否存在
+      } else {
+        console.error('用户未选择文件夹');
+        return false;
+      }
+    }
+
+
+    console.log('aaaa2')
+    const res = await openCameraControlCmd();
+    return res;
+  } catch (error) {
+    console.error('检查 CameraControlCmd.exe 是否存在时出错:', error);
+    throw error;
+  }
+}
+
+
+async function openCameraControlCmd() {
+ return  new Promise(async (resolve, reject) => {
+    try {
+      // 获取 digiCamControl 文件夹路径
+      const digiCamControlPath = config.digiCamControl;
+
+      // 拼接 CameraControlCmd.exe 的完整路径
+      const exePath = path.join(digiCamControlPath, 'CameraControl.exe');
+
+      // 检查文件是否存在
+      await fs.promises.access(exePath, fs.constants.F_OK);
+      try {
+
+          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;
+      }
 
+      console.log('CameraControlCmd.exe start');
+    } catch (error) {
+      console.error('无法找到或运行 CameraControlCmd.exe:', error);
+      throw error;
+    }
+  })
+}
 
 class CameraController extends Controller {
   constructor(ctx) {
     super(ctx);
   }
 
+  async connect() {
+    const win = this.app.electron.mainWindow;
+    try {
+      win.setAlwaysOnTop(true); // 置顶
+      console.log('aaaa')
+       await checkCameraControlCmdExists()
+      await  CMD('All_Minimize')
+      win.setAlwaysOnTop(false); // 置顶
+
+      const res = await getParams('iso')
+      if(res  === '未将对象引用设置到对象的实例。'){
+        return {
+          status:-1,
+          msg:"相机未连接,请链接相机。",
+        }
+      }
+      return {
+        status:2,
+        msg:res,
+      }
+      return true;
+    } catch (error) {
+      win.setAlwaysOnTop(false); // 置顶
+      return {
+        status:-1,
+        msg:"请安装digiCamControl软件,并打开digiCamControl软件的web服务,端口为5513",
+      }
+    }
+  }
+
   /**
    * 启动预览
    */
   async liveShow() {
     try {
       await liveShow();
-      const win = this.app.electron.mainWindow;
-      win.setAlwaysOnTop(true); // 置顶
+      await  CMD('All_Minimize')
       return true;
     } catch (error) {
       console.error('eeee启动直播失败:', error);
@@ -26,22 +163,18 @@ class CameraController extends Controller {
     }
   }
 
-
   /**
    * 结束预览
    */
   async liveHide() {
     try {
       await liveHide();
-      const win = this.app.electron.mainWindow;
-      win.setAlwaysOnTop(false); // 置顶
       return true;
     } catch (error) {
       throw error;
     }
   }
 
-
   /**
    * 设置参数
    */
@@ -63,6 +196,25 @@ class CameraController extends Controller {
       throw error;
     }
   }
+
+  // 示例:使用 fetchData 函数进行 HTTP 请求
+  async fetchExampleData() {
+    const options = {
+      hostname: 'example.com',
+      port: 443,
+      path: '/api/data',
+      method: 'GET'
+    };
+
+    try {
+      const data = await fetchData(options);
+      console.log('Fetched data:', data);
+      return data;
+    } catch (error) {
+      console.error('Fetch data failed:', error);
+      throw error;
+    }
+  }
 }
 
 CameraController.toString = () => '[class CameraController]';

+ 42 - 17
electron/controller/socket.js

@@ -13,27 +13,50 @@ class SocketController extends Controller {
   /**
    * Connect to WebSocket server
    */
-  connect() {
-    socket = new WebSocket('ws://10.56.42.176:7074/ws');
+  async connect() {
+    if(socket)  return;
 
-    const win = CoreWindow.getMainWindow()
-    // 监听连接成功事件
-    socket.on('open', () => {
-      return true;
-    });
+    return new Promise(async (resolve,reject) => {
+      socket = new WebSocket('ws://10.56.42.176:7074/ws');
 
-    // 监听消息事件
-    socket.on('message', (data) => {
-      win.webContents.send('controller.socket.message', data.toString());
-    });
+      const win = CoreWindow.getMainWindow()
+      // 监听连接成功事件
+      socket.on('open', () => {
+        console.log('socket open')
+        resolve(true);
+      });
 
-    // 监听连接关闭事件
-    socket.on('close', () => {
-    });
+      // 监听消息事件
+      socket.on('message', (data) => {
+        try {
+          let this_data = JSON.parse(data.toString());
+          if(this_data.msg_type){
+            let channel = 'controller.socket.message_'+this_data.msg_type;
+            win.webContents.send(channel, this_data);
+            //   win.webContents.send('controller.socket.message', data.toString());
 
-    // 监听错误事件
-    socket.on('error', (err) => {
-    });
+          }
+        }catch (e){
+          console.log(e)
+        }
+      });
+
+      // 监听连接关闭事件
+      socket.on('close', () => {
+        console.log('socket close');
+
+      });
+
+      // 监听错误事件
+      socket.on('error', (err) => {
+        console.log('socket error');
+        console.log(error);
+        reject(true);
+
+      });
+
+
+    })
 
   }
 
@@ -51,6 +74,8 @@ class SocketController extends Controller {
    */
   sendMessage(message) {
     // 检查连接状态
+    console.log(message);
+    console.log(typeof socket);
     if (socket?.readyState === WebSocket.OPEN) {
       socket.send(message); // 使用 send() 发送
     } else {

+ 31 - 40
frontend/src/components/check/index.vue

@@ -23,12 +23,12 @@
               <template v-else>初始化检测硬件失败</template>
             </div>
             <el-progress
-              :percentage="progress"
+              :percentage="checkInfoStore.getProgress"
               :colors="['#2FB0FF', '#B863FB']"
               :stroke-width="8"
               v-if="checkLoading"
             ></el-progress>
-            <div class="check-error-result" v-else-if="!checkSuccess">失败的原因,比如请检查硬件链接</div>
+            <div class="check-error-result" v-else-if="!checkSuccess">失败的原因,{{ checkInfoStore.getErrorMsg }}</div>
           </div>
         </el-timeline-item>
 
@@ -54,7 +54,7 @@
             <div class="check-btn" @click="reCheck">重新监测</div>
         </div>
         <div class="flex" v-else>
-            <div class="check-btn">正常,开始下一步</div>
+            <div class="check-btn cu-p" style="width: 180px" @click="confirm()">正常,开始下一步</div>
         </div>
     </template>
   </el-dialog>
@@ -62,10 +62,7 @@
 
 <script setup>
 import { ref, computed, watch, onBeforeUnmount, nextTick, watchEffect } from 'vue';
-import icpList from '@/utils/ipc'
-import client from "@/stores/modules/client";
 import useUserInfo from "@/stores/modules/user";
-import socket from "@/stores/modules/socket";
 import checkInfo from "@/stores/modules/check";
 
 /**
@@ -86,6 +83,8 @@ const props = defineProps({
 });
 
 
+// 初始化用户信息状态管理
+const useUserInfoStore = useUserInfo()
 const checkInfoStore = checkInfo()
 
 // 检测是否成功的状态
@@ -101,7 +100,6 @@ const emit = defineEmits(['update:modelValue', 'confirm']);
 const checkCount = ref(0);
 
 // 进度条的当前进度值
-const progress = checkInfoStore.getProgress
 
 // 定时器变量,用于控制进度条的递增
 let timer = null;
@@ -109,13 +107,14 @@ let timer = null;
 // 控制组件可见性的状态
 const visible = ref(false);
 
+
 /**
  * 开始进度条的递增逻辑。
  * 该函数会重置进度条并启动定时器,逐步增加进度值直到达到 80。
  */
 function startProgress() {
-  progress.value = 0;
   checkLoading.value = true;
+  checkInfoStore.reCheckAction()
 }
 
 /**
@@ -124,18 +123,10 @@ function startProgress() {
  */
 function reCheck() {
   startProgress()
-  listenerMessage()
+ // checkInfoStore.reCheckAction()
 }
 
 // 初始化客户端状态管理
-const clientStore = client();
-
-// 初始化用户信息状态管理
-const useUserInfoStore = useUserInfo()
-
-// 初始化 WebSocket 状态管理
-const socketStore = socket()
-
 
 /**
  * 监听用户信息和检测次数的变化,自动触发相关逻辑。
@@ -144,42 +135,42 @@ const socketStore = socket()
  */
 watchEffect(async ()=>{
   if( useUserInfoStore.userInfo.id && checkCount.value === 0){
-  //  console.log('aaa')
-    await socketStore.disconnectSocket()
-    console.log('watchEffect');
-    checkCount.value++;
-    await socketStore.connectSocket()
     visible.value = true
     startProgress()
-    listenerMessage()
+    checkCount.value++;
+  }
+})
 
+watchEffect(async ()=>{
+  if(checkInfoStore.getProgress === 100 ){
+    checkLoading.value = false;
+    checkSuccess.value = true;
   }
 })
 
 
-async function listenerMessage(){
-
-/*  //发送设备连接检测请求
-  await socketStore.sendMessage({
-    type: 'connect_mcu',
-  })
-*/
-  //发送遥控器请求
-/*  await socketStore.sendMessage({
-    type: 'connect_bluetooth',
-  })*/
-  if(clientStore.isClient){
-    clientStore.ipc.removeAllListeners(icpList.socket.message);
-    clientStore.ipc.on(icpList.socket.message, async (event, result) => {
-      console.log(result);
-    })
+
+
+watchEffect(async ()=>{
+  if( checkInfoStore.getErrorMsg){
+    checkLoading.value = false;
+    checkSuccess.value = false;
   }
+})
 
+watchEffect(async ()=>{
+  if( checkInfoStore.getProgress   === 1){
+    checkLoading.value = false;
+    checkSuccess.value = true;
+  }
+})
 
 
+function confirm(){
+  visible.value = false;
+  emit('confirm')
 }
 
-
 </script>
 
 

+ 1 - 1
frontend/src/router/index.ts

@@ -6,7 +6,7 @@ import { authGuard } from './plugins/authGuard'
 const routes: RouteRecordRaw[] = [
     {
         path: "/",
-        redirect: "/home"
+        redirect: "/photography/check"
     },
     {
         path: "/home",

+ 134 - 106
frontend/src/stores/modules/check.ts

@@ -4,137 +4,165 @@ import socket from "./socket";
 import icpList from "../../utils/ipc";
 import client from "./client";
 
-const socketStore = socket()
-// 初始化客户端状态管理
+const socketStore = socket();
 const clientStore = client();
 
-export const checkInfo = defineStore('checkInfo',()=>{
-
-    //status  -1连接失败  0未连接 1连接中  2链接成功  3端口占用
-    //拍照设备
-    const mcu = reactive({
-        status:0,
-        msg_type:"mcu",
-        msg:"未连接",
-    })
-
-    //遥控器
-    const blueTooth = reactive({
-        status:0,
-        msg_type:"blue_tooth",
-        msg:"未连接",
-    })
-
-    //camControl 打开digiCamControl 通过端口  5513 来判断是否链接上了
-    const camControl = reactive({
-        status:0,
-        msg_type:"cam_control",
-        msg:"未连接",
-    })
-
-    //相机
-    const camera = reactive({
-        status:0,
-        msg_type:"cam_control",
-        msg:"未连接",
-    })
-
-
-    const getProgress = computed(()=>{
+export const checkInfo = defineStore('checkInfo', () => {
+    // 定义设备列表
+    const devices = reactive({
+/*        mcu: {
+            status: 0,
+            msg_type: "connect_mcu",
+            msg: "未连接",
+        },
+        blue_tooth: {
+            status: 0,
+            msg_type: "connect_bluetooth",
+            msg: "未连接",
+        },*/
+        cam_control: {
+            status: 0,
+            msg_type: "cam_control",
+            msg: "未连接",
+        },
+/*        camera: {
+            status: 0,
+            msg_type: "camera",
+            msg: "未连接",
+        },*/
+    });
+
+    const checkTime = ref(0)
+    let CKTimerInterval:any = null
+
+    // 计算完成进度
+    const getProgress = computed(() => {
         let completed = 0;
-        let total = 4;
-        if(mcu.status === 2) completed++;
-        if(blueTooth.status === 2) completed++;
-        if(camControl.status === 2) completed++;
-        if(camera.status === 2) completed++;
-        return Number(completed/total)*100
-    })
+        const total = Object.keys(devices).length;
+        for (const device of Object.values(devices)) {
+            if (device.status === 2) completed++;
+        }
+        return parseFloat((completed / total * 100).toFixed(2));
+    });
+
+    // 获取错误信息
+    const getErrorMsg = computed(() => {
+        for (const device of Object.values(devices)) {
+            if (device.status === -1) {
+                clearInterval(CKTimerInterval)
+                checkTime.value = 0
+                return device.msg;
+            }
+        }
+        return null;
+    });
 
+    const checkcamControl = async ()=>{
 
-    const getErrorMsg = computed(()=>{
-        if(mcu.status === -1) return mcu.msg
-        if(blueTooth.status === -1) return blueTooth.msg
-        if(camControl.status === -1) return camControl.msg
-        if(camera.status === -1) return camera.msg
-    })
 
+              clientStore.ipc.removeAllListeners(icpList.camera.connect);
+              clientStore.ipc.send(icpList.camera.connect);
+              clientStore.ipc.on(icpList.camera.connect, async (event, result) => {
 
 
-    const checkAction = async (data: any) => {
-        await socketStore.disconnectSocket()
-        await socketStore.connectSocket()
-        await checkMCU()
-        await checkblueTooth()
+                  console.log('icpList.camera.connect');
+                  console.log(result);
+                  if (result && checkTime.value > 0) {
+                      if([-1,0,2].includes(result.status)){
+                          devices.cam_control.status = result.status;
+                          devices.cam_control.msg = result.msg;
+                      }
+                  }
+              });
 
-        await checkCamControl()
-        await checkCamera()
-    };
+    }
 
 
-    const checkMCU = async (data: any) => {
-        await socketStore.sendMessage({
-            type: 'connect_mcu',
-        })
-        if(clientStore.isClient){
-            clientStore.ipc.removeAllListeners(icpList.socket.check.mcu);
-            clientStore.ipc.on(icpList.socket.check.mcu, async (event, result) => {
-              if(result){
-                  mcu.status = result.status
-                  mcu.msg = result.msg
-              }
-            })
-        }
-    };
-    const checkblueTooth = async (data: any) => {
-        await socketStore.sendMessage({
-            type: 'blueTooth',
-        })
-        if(clientStore.isClient){
-            clientStore.ipc.removeAllListeners(icpList.socket.check.blueTooth);
-            clientStore.ipc.on(icpList.socket.check.blueTooth, async (event, result) => {
-                if(result){
-                    blueTooth.status = result.status
-                    blueTooth.msg = result.msg
+    const checkcamera = ()=>{
+        clientStore.ipc.removeAllListeners(icpList.camera.hascamera);
+        clientStore.ipc.send(icpList.camera.hascamera);
+        clientStore.ipc.on(icpList.camera.hascamera, (event, result) => {
+            if (result && checkTime.value > 0) {
+                if([-1,0,2].includes(result.status)){
+                    devices.cam_control.status = result.status;
+                    devices.cam_control.msg = result.msg;
                 }
-            })
-        }
-    };
-    const checkCamControl = async (data: any) => {
+            }
+            console.log(result);
+        });
 
-        clientStore.ipc.removeAllListeners(icpList.socket.check.camControl);
+    }
 
-        clientStore.ipc.send(icpList.socket.check.camControl);
+    // 通用设备检查函数
+    const checkDevice = async (deviceName: string, messageType: string) => {
+        try {
+            await socketStore.connectSocket();
+            await socketStore.sendMessage({ type: messageType });
+            clientStore.ipc.on(icpList.socket.message+'_'+deviceName, (event, result) => {
+                if (result && checkTime.value > 0) {
+                    if([-1,0,2].includes(result.status)){
+                        devices[deviceName].status = result.status;
+                        devices[deviceName].msg = result.msg;
+                    }
+                }
+            });
+        } catch (error) {
+            console.error(`Error checking ${deviceName}:`, error);
+            devices[deviceName].status = -1;
+            devices[deviceName].msg = `检查失败: ${error.message}`;
+        }
+    };
 
-        clientStore.ipc.on(icpList.socket.check.camControl, async (event, result) => {
-            if(result){
-                camControl.status = result.status
-                camControl.msg = result.msg
+    // 执行所有设备检查
+    const checkAction = async () => {
+        for (const deviceName of Object.keys(devices)) {
+            switch (deviceName){
+                case 'cam_control':
+                    await checkcamControl();
+                    break;
+                case 'camera':
+                 //   await checkcamera();
+                    break;
+                 default:
+                     await checkDevice(deviceName, devices[deviceName].msg_type);
             }
+        }
 
-        })
     };
-    const checkCamera = async (data: any) => {
-        clientStore.ipc.removeAllListeners(icpList.socket.check.camera);
 
-        clientStore.ipc.send(icpList.socket.check.camera);
+    // 重新检查所有设备
+    const reCheckAction = async () => {
+        for (const device of Object.values(devices)) {
+            device.status = 0;
+            device.msg = "未连接";
+        }
+        checkTime.value++;
+        CKTimerInterval = setInterval(()=>{
+            checkTime.value++;
+
 
-        clientStore.ipc.on(icpList.socket.check.camera, async (event, result) => {
-            if(result){
-                camera.status = result.status
-                camera.msg = result.msg
+            if(checkTime.value >= 60){
+                if( devices.blue_tooth &&  devices.blue_tooth.status === 0){
+                    devices.blue_tooth.status = -1;
+                    devices.blue_tooth.msg = '遥控器未连接。';
+                }
             }
+        },1000)
+        await checkAction();
 
-        })
     };
 
+
     return {
         getProgress,
-        mcu,
-        blueTooth,
-        camControl,
-        camera
-    }
-})
-
+        getErrorMsg,
+        mcu: devices.mcu,
+        blueTooth: devices.blueTooth,
+        camControl: devices.camControl,
+        camera: devices.camera,
+        checkAction,
+        reCheckAction,
+    };
+});
 
 export default checkInfo;

+ 0 - 3
frontend/src/stores/modules/socket.ts

@@ -16,9 +16,6 @@ const socket = defineStore('socket', ()=>{
             clientStore.ipc.removeAllListeners(icpList.socket.connect);
             clientStore.ipc.send(icpList.socket.connect);
             clientStore.ipc.on(icpList.socket.connect, async (event, result) => {
-
-                console.log('on icpList.socket.connect');
-                console.log(result);
                 socket.value = result
                 resolve(result)
             })

+ 5 - 1
frontend/src/utils/appconfig.ts

@@ -8,4 +8,8 @@ export const imagesUploadLimit = {
   accept: ['jpg', 'jpeg', 'png'],
   fileSize: 2048 * 10,
   fileLimit: '20MB'
-}
+}
+
+export const digiCamControlWEB =  'http://localhost:5513/'
+
+

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

@@ -1,5 +1,6 @@
 const icpList = {
     camera:{
+        connect: 'controller.camera.connect',
         PreviewShow: 'controller.camera.liveShow',
         PreviewHide: 'controller.camera.liveHide',
         setParams:"controller.camera.setParams",
@@ -11,12 +12,6 @@ const icpList = {
         message: 'controller.socket.message',
         sendMessage: 'controller.socket.sendMessage',
         disconnect: 'controller.socket.disconnect',
-        check:{
-            mcu: 'controller.socket.check.mcu',
-            blueTooth: 'controller.socket.check.blueTooth',
-            camControl: 'controller.socket.check.camControl',
-            camera: 'controller.socket.check.camera',
-        }
     },
     utils:{
         openMain: 'controller.utils.openMain',

+ 69 - 18
frontend/src/views/Photography/check.vue

@@ -3,33 +3,37 @@
     <div class="main-container flex-col">
       <div class="content-wrapper flex-row justify-between">
         <div class="left-panel flex-col justify-between">
-          <div class="tips-container flex-row">
+          <div class="tips-container flex-row" v-if="show">
             <img class="tips-icon" referrerpolicy="no-referrer" src="@/assets/images/Photography/tips-icon.png" />
             <span class="tips-tex">请在圆盘上摆上鞋子(注意左右脚),要求鞋外侧朝向拍照机,鞋子中轴线和红外线对齐</span>
-            <img class="close-icon" referrerpolicy="no-referrer" src="@/assets/images/Photography/close-icon.png" />
+            <img class="close-icon cu-p" referrerpolicy="no-referrer" src="@/assets/images/Photography/close-icon.png"  @click="show = false"/>
           </div>
           <div class="camera-preview  flex col center ">
-            <span v-if="!imageUrl" class="fs-14">这是一个面对鞋子的镜头</span>
-            <img v-if="imageUrl" class="camera-img" :src="imageUrl" />
-            <span v-if="imageUrl" class="camera-description">这是一张用于检查镜头是否合适的测试图</span>
+            <span v-if="step === 1" class="fs-14">
+               <img v-if="previewKey" class="camera-img" :src="preview+'?key='+previewKey" />
+            </span>
+            <template v-if="step === 2" >
+              <img class="camera-img" :src="imageUrl+'?key='+imageUrlkey" />
+              <span  class="camera-description">这是一张用于检查镜头是否合适的测试图</span>
+            </template>
           </div>
         </div>
         <div class="example-image flex-col"><span class="example-text">示范图片</span></div>
       </div>
-      <div v-if="!imageUrl" class="action-button flex cente">
+      <div v-if="step === 1" class="action-button flex cente">
         <div @click="takePictures" class="check-button  button--primary1 flex-col"><span class="button-text">拍照检查</span>
         </div>
       </div>
 
       <div v-else class="action-button flex center">
-        <div @click="takePictures" class="check-button  button--white flex-col">
-          <span class="button-text">重新拍照检查</span>
+        <div @click="checkConfirm" class="check-button  button--white flex-col">
+          <span class="button-text cu-p">重新拍照检查</span>
         </div>
         <router-link class="mar-left-20 " :to="{
           name: 'PhotographyShot'
         }">
           <div class="check-button   button--primary1 flex-col">
-            <span class="button-text">确认无误,下一步</span>
+            <span class="button-text cu-p">确认无误,下一步</span>
           </div>
         </router-link>
 
@@ -38,7 +42,9 @@
   </div>
 
 
-  <hardware-check/>
+  <hardware-check
+   @confirm="checkConfirm"
+  />
 </template>
 <script setup lang="ts">
 import  { watchEffect } from  'vue'
@@ -47,7 +53,7 @@ import icpList from '@/utils/ipc'
 import useUserInfo from "@/stores/modules/user";
 const clientStore = client();
 
-
+const show = ref(true)
 
 const useUserInfoStore = useUserInfo()
 import HardwareCheck from '@/components/check/index.vue'
@@ -57,10 +63,52 @@ function onCheckComplete(){
 
 import { ref } from 'vue'
 import socket from "../../stores/modules/socket";
-const url = ref('https://ossimg.valimart.net/uploads/vali_ai/20240312/171022217892595.png')
-const imageUrl = ref('')
+import { digiCamControlWEB } from  '@/utils/appconfig'
+const imageUrl = ref(digiCamControlWEB+'preview.jpg')
+const imageUrlkey = ref(0)
 const previewKey = ref(0)
-const preview = ref('http://localhost:5513/preview.jpg')
+const preview = ref(digiCamControlWEB+'liveview.jpg')
+
+const step = ref(1)
+function checkConfirm(){
+  step.value =1
+  showVideo()
+}
+
+
+
+
+
+
+let interval:any = null
+function showVideo(){
+
+    clientStore.ipc.removeAllListeners(icpList.camera.PreviewShow);
+
+    clientStore.ipc.send(icpList.camera.PreviewShow);
+    clientStore.ipc.on(icpList.camera.PreviewShow, async (event, result) => {
+
+      setTimeout(()=>{
+        interval = setInterval(()=>{
+          previewKey.value++;
+        },200)
+      },2000)
+
+    })
+
+}
+
+function hideVideo(){
+  if(clientStore.isClient){
+
+    clientStore.ipc.removeAllListeners(icpList.camera.PreviewHide);
+    clientStore.ipc.send(icpList.camera.PreviewHide);
+    clientStore.ipc.on(icpList.camera.PreviewHide, async (event, result) => {
+      if(interval) clearInterval(interval)
+    })
+  }
+
+}
 
 
 function takePictures() {
@@ -68,10 +116,13 @@ function takePictures() {
     clientStore.ipc.removeAllListeners(icpList.camera.takePictures);
     clientStore.ipc.send(icpList.camera.takePictures);
     clientStore.ipc.on(icpList.camera.takePictures, async (event, result) => {
-      setTimeout(() => {
-        previewKey.value++;
-        preview.value = `http://localhost:5513/preview.jpg?key=${previewKey.value}`
-      }, 1000)
+
+
+      setTimeout(()=>{
+        hideVideo()
+        step.value = 2
+        imageUrlkey.value++;
+      },5000)
     })
   }
 }