林旭祥 il y a 1 semaine
Parent
commit
ab71d71bc5
2 fichiers modifiés avec 7 ajouts et 2 suppressions
  1. 6 1
      src/components/OnlineFaceWindow/index.vue
  2. 1 1
      src/utils/faceWs.ts

+ 6 - 1
src/components/OnlineFaceWindow/index.vue

@@ -27,7 +27,7 @@ import { initSpeech, speckText, playMusic, controlMusic, speckCancel, chineseNum
 import { useWebSocket } from '@/utils/faceWs';
 const { proxy } = getCurrentInstance() as any;
 const router = useRouter();
-const { faceWs, startDevice, checkFace, openFace, terminateFace, suspendFace, resumeFace, getFaceState } = useWebSocket();
+const { faceWs, startDevice, checkFace, openFace, terminateFace, suspendFace, resumeFace, getFaceState, closeWS } = useWebSocket();
 
 const data = reactive<any>({
   faceCheckStu: {},//人脸信息
@@ -168,6 +168,11 @@ const getCloseFace = () => {
   terminateFace(handcontroller_id);
   faceState.value = false;
   speckCancel(); //停止播报
+  setTimeout(() => {
+    if (wsState.value) {
+      closeWS();
+    }
+  }, 3000)
 };
 
 //暴露给父组件用

+ 1 - 1
src/utils/faceWs.ts

@@ -168,5 +168,5 @@ export function useWebSocket() {
     closeWS();
   });
 
-  return { faceWs, startDevice, sendMessage, checkFace, openFace, terminateFace, suspendFace, resumeFace, getFaceState };
+  return { faceWs, startDevice, sendMessage, checkFace, openFace, terminateFace, suspendFace, resumeFace, getFaceState, closeWS };
 }