Преглед изворни кода

fix(Photography): 修复智慧射手机型拍照后未及时刷新相册的问题

- 在 check.vue 和 shot.vue 中添加智慧射手拍照成功的事件监听
- 拍照成功后设置定时器,延迟 2 秒后刷新相册
- 优化了拍照流程,确保用户能够及时看到拍摄的照片
panqiuyao пре 4 месеци
родитељ
комит
ec884baf22

+ 8 - 3
frontend/src/views/Photography/check.vue

@@ -151,8 +151,12 @@ async function checkConfirm(init){
   showrEditRow.value = true
 }
 
+const init = ref(true)
 function onRunMcuSingle (){
-  loading.value = false
+  if(init.value) {
+    loading.value = false
+    init.value = false
+  }
 }
 const showrEditRow = ref(false)
 
@@ -254,8 +258,9 @@ function  createMainImage (file_path){
 
 //拍照成功  SmartShooter
 clientStore.ipc.on(icpList.socket.message+'_smart_shooter_photo_take', async (event, result) => {
-
-  if(result.code === 1 && result.data?.photo_file_name){
+  console.log('_smart_shooter_photo_take');
+  console.log(result);
+  if(result.code === 0 && result.data?.photo_file_name){
     createMainImage(result.data?.photo_file_name)
   }
 

+ 18 - 0
frontend/src/views/Photography/shot.vue

@@ -720,6 +720,7 @@ onBeforeUnmount(() => {
   clientStore.ipc.removeAllListeners(icpList.socket.message + '_photo_take_finish');
   clientStore.ipc.removeAllListeners(icpList.socket.message + '_run_mcu_update');
   clientStore.ipc.removeAllListeners(icpList.socket.message + '_stop_action');
+  clientStore.ipc.removeAllListeners(icpList.socket.message + '_smart_shooter_photo_take');
 /*  window.removeEventListener('storage', handleStorageEvent);*/
 
 
@@ -757,6 +758,23 @@ const  getLastPhotoRecord = async ()=>{
   });
 }
 
+let smartShooterTimeout = null; // 在合适的位置定义一个全局变量用于保存定时器
+
+//拍照成功  SmartShooter
+clientStore.ipc.on(icpList.socket.message+'_smart_shooter_photo_take', async (event, result) => {
+  console.log('_smart_shooter_photo_take');
+  console.log(result);
+  if(result.code === 0 && result.data?.photo_file_name){
+    if (smartShooterTimeout) {
+      clearTimeout(smartShooterTimeout);
+    }
+    smartShooterTimeout = setTimeout(() => {
+      getPhotoRecords();
+    }, 2000);
+  }
+
+})
+
 
 // 监听拍照完成后的最终状态事件
 clientStore.ipc.on(icpList.socket.message + '_run_mcu_update', (event, result) => {

+ 1 - 1
public/dist/index.html

@@ -5,7 +5,7 @@
     <link rel="icon" type="image/svg+xml" href="./vite.svg" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>智惠映AI自动拍照机</title>
-    <script type="module" crossorigin src="./assets/index-CBoEZzqz.js"></script>
+    <script type="module" crossorigin src="./assets/index-Dx7tl9Wa.js"></script>
     <link rel="stylesheet" crossorigin href="./assets/index-CWbjMgyJ.css">
   </head>
   <body>