林旭祥 2 هفته پیش
والد
کامیت
7e90cf09ed
3فایلهای تغییر یافته به همراه19 افزوده شده و 4 حذف شده
  1. 15 3
      src/components/OnlineFaceWindow/index.vue
  2. 2 0
      src/types/components.d.ts
  3. 2 1
      src/utils/faceWs.ts

+ 15 - 3
src/components/OnlineFaceWindow/index.vue

@@ -43,9 +43,10 @@ const data = reactive<any>({
   deviceInfo: {},//设备信息
   again: false,//是否再次启动
   againNum: 0,//再次启动次数
+  wsState: false,//WS状态
 });
 
-const { faceCheckStu, faceState, direction, parameter, deviceInfo, again, againNum } = toRefs(data);
+const { faceCheckStu, faceState, direction, parameter, deviceInfo, again, againNum, wsState } = toRefs(data);
 
 onBeforeMount(() => {
 })
@@ -63,9 +64,18 @@ const getInit = async () => {
     proxy?.$modal.msgError(`请重新登录绑定设备号后使用`);
     return false;
   }
+  faceState.value = true;
+  if (wsState.value) {
+    proxy?.$modal.msgWarning(`操作过快,请稍后重试`);
+    setTimeout(() => {
+      faceState.value = false;
+    }, 1000)
+    return false;
+  }
   faceWs((e: any) => {
-    console.log("faceWS",e)
+    console.log("faceWS", e)
     if (e?.wksid) {
+      wsState.value = true;
       //获取设备信息
       startDevice({ deviceid: deviceid });
       console.log("获取设备信息")
@@ -112,7 +122,6 @@ const getInit = async () => {
         getCloseFace();
         proxy?.$modal.msgWarning(`请重新人脸识别`);
       } else {
-        faceState.value = true;
         openFace(handcontroller_id);
       }
     }
@@ -139,6 +148,9 @@ const getInit = async () => {
         faceState.value = false;
       }
     }
+    if (e?.type == 'disconnect') {
+      wsState.value = false;
+    }
   });
 };
 

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

@@ -10,8 +10,10 @@ declare module 'vue' {
     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']

+ 2 - 1
src/utils/faceWs.ts

@@ -38,7 +38,8 @@ export function useWebSocket() {
       callback(e);
     });
     socketFace.on('disconnect', (e: any) => {
-      callback(e);
+      let obj = { type: "disconnect" };
+      callback(obj);
     });
   }