Bladeren bron

Merge branch 'dev-frontend' of http://gitlab.pubdata.cn/liangyibo/CameraMachine into dev-frontend

kongwenhao 8 maanden geleden
bovenliggende
commit
78ee2ef824

+ 1 - 1
frontend/src/components/check/index.vue

@@ -51,7 +51,7 @@
     </div>
     <template #footer v-if="!checkLoading">
         <div class="flex" v-if="!checkSuccess">
-            <div class="check-btn" @click="reCheck">重新监测</div>
+            <div class="check-btn cu-p" @click="reCheck">重新监测</div>
         </div>
         <div class="flex" v-else>
             <div class="check-btn cu-p" style="width: 180px" @click="confirm()">正常,开始下一步</div>

+ 38 - 1
frontend/src/stores/modules/check.ts

@@ -8,6 +8,7 @@ const socketStore = socket();
 const clientStore = client();
 
 export const checkInfo = defineStore('checkInfo', () => {
+
     // 定义设备列表
     const devices = reactive({
         mcu: {
@@ -35,6 +36,11 @@ export const checkInfo = defineStore('checkInfo', () => {
     const checkTime = ref(0)
     let CKTimerInterval:any = null
 
+    //mcu 初始化
+    const mcu = reactive({
+        isInitSend:false,
+        status:0,
+    })
     // 计算完成进度
     const getProgress = computed(() => {
         let completed = 0;
@@ -47,10 +53,18 @@ export const checkInfo = defineStore('checkInfo', () => {
 
     // 获取错误信息
     const getErrorMsg = computed(() => {
+
+        if(mcu.status === -1){
+            clearInterval(CKTimerInterval)
+            checkTime.value = 0
+            mcu.isInitSend = false
+            return '相机初始化失败,请重新监测或强制初始化!';
+        }
         for (const device of Object.values(devices)) {
             if (device.status === -1) {
                 clearInterval(CKTimerInterval)
                 checkTime.value = 0
+                mcu.isInitSend = false
                 return device.msg;
             }
         }
@@ -99,8 +113,31 @@ export const checkInfo = defineStore('checkInfo', () => {
             await socketStore.connectSocket();
             await socketStore.sendMessage({ type: messageType });
             clientStore.ipc.on(icpList.socket.message+'_'+deviceName, (event, result) => {
+
+                console.log(result);
                 if (result && checkTime.value > 0) {
-                    if([-1,0,2].includes(result.status)){
+                    if(deviceName === 'mcu'){
+                        console.log(result);
+                        if(result.status === 2 ){
+                            if(!mcu.isInitSend){
+                                socketStore.sendMessage({ type: 'init_mcu' });
+                                mcu.isInitSend = true
+                                mcu.status = 1
+                            }
+                            if(mcu.isInitSend && result.msg === '设备初始化完成'){
+                                devices[deviceName].status = result.status;
+                                devices[deviceName].msg = result.msg;
+                                mcu.status = 2
+                            }
+                            if(checkTime.value >= 60 &&   mcu.status !== 2){
+                                mcu.status == -1;
+                            }
+                        }
+                        if([-1,0].includes(result.status)){
+                            devices[deviceName].status = result.status;
+                            devices[deviceName].msg = result.msg;
+                        }
+                    }else if([-1,0,2].includes(result.status)){
                         devices[deviceName].status = result.status;
                         devices[deviceName].msg = result.msg;
                     }

+ 1 - 1
frontend/src/stores/modules/user.ts

@@ -52,7 +52,7 @@ export const useUserInfo = defineStore('userInfo', () => {
     try {
       const res = await login(data); // 调用登录接口
       await updateToken(res.data.token); // 更新登录令牌
-      await getInfo(); // 获取用户信息
+   //   await getInfo(); // 获取用户信息
       return res;
     } catch (error) {
       console.error('登录失败:', error);

+ 17 - 9
frontend/src/views/Photography/check.vue

@@ -28,12 +28,12 @@
           <div class="example-image flex-col"><span class="example-text">示范图片</span></div>
         </div>
         <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 @click="takePictures" class="check-button  button--primary1 flex-col"><span class="button-text" v-loading="loading">拍照检查</span>
           </div>
         </div>
 
         <div v-else class="action-button flex center">
-          <div @click="checkConfirm" class="check-button  button--white flex-col">
+          <div @click="checkConfirm(false)" class="check-button  button--white flex-col">
             <span class="button-text cu-p">重新拍照检查</span>
           </div>
           <router-link class="mar-left-20 " :to="{
@@ -51,7 +51,7 @@
   </div>
 
   <hardware-check
-   @confirm="checkConfirm"
+   @confirm="checkConfirm(true)"
   />
 </template>
 <script setup lang="ts">
@@ -80,11 +80,15 @@ const previewKey = ref(0)
 const preview = ref(digiCamControlWEB+'liveview.jpg')
 
 const step = ref(1)
-function checkConfirm(){
+function checkConfirm(init){
   step.value =1
-  menu.push({
-    type:'setting'
-  })
+  if(menu.length === 0){
+    menu.push({
+      type:'setting'
+    })
+  }
+  if(!init) previewKey.value++;
+
   showVideo()
 }
 
@@ -121,6 +125,7 @@ function hideVideo(){
 
 }
 
+const loading = ref(false)
 
 function takePictures() {
   if (clientStore.isClient) {
@@ -128,12 +133,15 @@ function takePictures() {
     clientStore.ipc.send(icpList.camera.takePictures);
     clientStore.ipc.on(icpList.camera.takePictures, async (event, result) => {
 
-
+      if(interval) clearInterval(interval)
+      loading.value = true;
+      imageUrlkey.value++;
       setTimeout(()=>{
         hideVideo()
         step.value = 2
         imageUrlkey.value++;
-      },5000)
+        loading.value = false;
+      },8000)
     })
   }
 }