ソースを参照

mod:运行并检查,

panqiuyao 8 ヶ月 前
コミット
d7b88f462e

+ 6 - 1
electron/api/camera.js

@@ -64,11 +64,16 @@ module.exports = {
       url: '?CMD=LiveViewWnd_Hide'
     })
   },
-  capture(){
+  captureLive(){
     return get({
       url: '?CMD=LiveView_Capture'
     })
   },
+  capture(){
+    return get({
+      url: '?CMD=Capture'
+    })
+  },
 
   CMD(cmd){
     return get({

+ 9 - 3
electron/controller/camera.js

@@ -4,7 +4,7 @@ const path = require('path');
 const fs = require('fs');
 const { Controller } = require('ee-core');
 const { spawn } = require('child_process');
-const { liveShow, liveHide, setParams, capture, getParams,CMD } = require('../api/camera');
+const { liveShow, liveHide, setParams, capture, getParams,CMD,captureLive } = require('../api/camera');
 const { dialog } = require('electron'); // 引入 electron 的 dialog 模块
 const { windowManager } = require('node-window-manager');
 // 检查并读取配置文件
@@ -203,9 +203,15 @@ class CameraController extends Controller {
     }
   }
 
-  async takePictures() {
+  async takePictures(isLive=true) {
     try {
-      await capture();
+      if(isLive){
+
+        await captureLive();
+      }else{
+
+        await capture();
+      }
       return true;
     } catch (error) {
       throw error;

+ 1 - 0
frontend/package.json

@@ -10,6 +10,7 @@
   },
   "dependencies": {
     "@element-plus/icons-vue": "2.3.1",
+    "@planckdev/element-plus": "0.0.0-rc.6",
     "@types/axios": "0.14.4",
     "axios": "1.8.3",
     "crypto-js": "4.1.1",

+ 13 - 1
frontend/src/views/Photography/check.vue

@@ -73,7 +73,7 @@ function onCheckComplete(){
 
 }
 
-import { ref } from 'vue'
+import { ref,onBeforeUnmount } from 'vue'
 import socket from "../../stores/modules/socket";
 import { digiCamControlWEB } from  '@/utils/appconfig'
 const imageUrl = ref(digiCamControlWEB+'preview.jpg')
@@ -147,6 +147,18 @@ function takePictures() {
     })
   }
 }
+
+
+/**
+ * 页面卸载时移除所有事件监听器。
+ */
+onBeforeUnmount(() => {
+  clientStore.ipc.removeAllListeners(icpList.camera.takePictures);
+  clientStore.ipc.removeAllListeners(icpList.camera.PreviewHide);
+  clientStore.ipc.removeAllListeners(icpList.camera.PreviewShow);
+
+
+})
 </script>
 <style scoped lang="scss">
 .check-wrap {

+ 28 - 3
frontend/src/views/Setting/index.vue

@@ -315,7 +315,7 @@
         <template #footer>
           <div class="btn-row">
             <div class="normal-btn" @click="dialogVisible = false">关闭</div>
-            <!-- <div class="primary-btn" @click="testShoesFlip">拍照测试</div> -->
+             <div class="primary-btn" v-loading="captureLoading" @click="testShoesFlip">拍照测试</div>
             <div class="primary-btn" @click="saveRow">保存并关闭</div>
           </div>
         </template>
@@ -339,8 +339,9 @@ import client from "@/stores/modules/client";
 import icpList from '@/utils/ipc';
 const clientStore = client();
 import { ElMessage, ElMessageBox } from 'element-plus';
-
+import { digiCamControlWEB } from  '@/utils/appconfig'
 import { useCheckInfo } from '@/composables/userCheck';
+import { preview } from '@planckdev/element-plus/utils'
 useCheckInfo();
 
 // 路由和状态管理初始化
@@ -811,9 +812,33 @@ async function changeNum(type, min, max) {
   }
 }
 
-</script>
 
+/*测试拍照*/
+const captureLoading = ref(false)
+const imageUrl = ref(digiCamControlWEB+'preview.jpg')
+const imageUrlkey = ref(0)
+function testShoesFlip(){
+  if (clientStore.isClient) {
+    clientStore.ipc.removeAllListeners(icpList.camera.takePictures);
+    clientStore.ipc.send(icpList.camera.takePictures,false);
+    clientStore.ipc.on(icpList.camera.takePictures, async (event, result) => {
+      captureLoading.value = true;
+      setTimeout(()=>{
+        imageUrlkey.value++;
+        preview(imageUrl.value+'?key='+imageUrlkey.value)
+        captureLoading.value = false;
+      },5000)
+    })
+  }
+}
+
+</script>
 
+<style lang="scss">
+.el-image-viewer__wrapper{
+  z-index: 9999 !important;
+}
+</style>
 <style lang="scss" scoped>
 body {
   background: #EAECED;