林旭祥 2 nedēļas atpakaļ
vecāks
revīzija
304b047108
2 mainītis faili ar 20 papildinājumiem un 23 dzēšanām
  1. 20 19
      src/components/OnlineFaceWindow/index.vue
  2. 0 4
      src/types/components.d.ts

+ 20 - 19
src/components/OnlineFaceWindow/index.vue

@@ -18,7 +18,7 @@
                 <img src="@/assets/images/test/facePicture.png" />
               </div>
               <div class="name" :class="{ 'name2': faceCheckStu.id }">
-                {{ faceCheckStu.id ? faceCheckStu.name : '请看摄像头进行人脸识别' }}
+                {{ faceCheckStu.id ? faceCheckStu.name : '请举右手看摄像头进行人脸识别' }}
               </div>
             </div>
           </div>
@@ -41,12 +41,12 @@ const data = reactive<any>({
   direction: "",//动画方向
   parameter: {},//参数
   deviceInfo: {},//设备信息
-  again: false,//是否再次启动
   againNum: 0,//再次启动次数
+  againTimer: null,//定时状态
   wsState: false,//WS状态
 });
 
-const { faceCheckStu, faceState, direction, parameter, deviceInfo, again, againNum, wsState } = toRefs(data);
+const { faceCheckStu, faceState, direction, parameter, deviceInfo, againNum, againTimer, wsState } = toRefs(data);
 
 onBeforeMount(() => {
 })
@@ -95,24 +95,31 @@ const getInit = async () => {
       if (e?.code == 0) {
         //查看人脸识别状态,如果不处于关闭就先关闭再重新启动(可能会APP退出然后工作站还在运行的可能性)
         getFaceState(handcontroller_id);
+        againNum.value = 0;
+        againTimer.value = null;
+        clearTimeout(againTimer.value);
         console.log("查看人脸识别状态")
       } else {
         let msg = "";
         if (e.code == 102402) {
-          //只能重启两次以免循环
-          if (againNum.value <= 1) {
-            msg = `人脸识别模块被占用,即将重新启动`;
-            again.value = true;
-          } else {
-            msg = `多次启动失败,请联系管理员`;
-            again.value = false;
-            againNum.value = 0;
-          }
+          msg = `人脸识别模块被占用,即将重新启动`;
         } else {
           msg = `人脸识别模块不可用,code:${e.code}`;
         }
+        //getCloseFace();//直接关闭
+        //尝试多次查询人脸识别状态
+        if (againNum.value <= 10) {
+          againTimer.value = setTimeout(() => {
+            getCheckFace();
+          }, 100)
+          againNum.value++;
+        } else {
+          msg = `多次失败,请联系管理员`;
+          againNum.value = 0;
+          againTimer.value = null;
+          clearTimeout(againTimer.value);
+        }
         proxy?.$modal.msgWarning(msg);
-        getCloseFace();
       }
     }
     if (e?.cmd == 'get_facecontroller_state') {
@@ -139,12 +146,6 @@ const getInit = async () => {
     }
     if (e?.cmd == 'terminate_facecontroller') {
       if (e?.code == 0) {
-        //自动重新启动人脸识别
-        if (again.value) {
-          getInit();
-          againNum.value++;
-        }
-        again.value = false;
         faceState.value = false;
       }
     }

+ 0 - 4
src/types/components.d.ts

@@ -8,12 +8,8 @@ export {}
 declare module 'vue' {
   export interface GlobalComponents {
     ChooseStudent: typeof import('./../components/ChooseStudent/index.vue')['default']
-    ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
-    ElIcon: typeof import('element-plus/es')['ElIcon']
-    ElInput: typeof import('element-plus/es')['ElInput']
     ElOption: typeof import('element-plus/es')['ElOption']
     ElSelect: typeof import('element-plus/es')['ElSelect']
-    ElSwitch: typeof import('element-plus/es')['ElSwitch']
     FaceWindow: typeof import('./../components/FaceWindow/index.vue')['default']
     Header: typeof import('./../components/Header/index.vue')['default']
     JumpRopeGame: typeof import('./../components/JumpRopeGame/index.vue')['default']