Ver código fonte

WS未联网情况下处理退出

林旭祥 6 meses atrás
pai
commit
997827dd71
2 arquivos alterados com 5 adições e 9 exclusões
  1. 5 3
      src/utils/trainWs.ts
  2. 0 6
      src/views/train/multiple.vue

+ 5 - 3
src/utils/trainWs.ts

@@ -47,20 +47,22 @@ export function useWs() {
       return obj;
     });
     loadingTime = setTimeout(() => {
-      //30秒还在0状态就算超时
+      //20秒还在0状态就算超时
       let list = examStateList.filter((item: any) => {
         return item.examState == 0;
       });
       //考虑到多开只有一个在线也有效的
       if (list.length == testList.length) {
         clearTimeout(loadingTime);
-        callback({ cmd: 'disconnect_request', data: { message: 'WS连接超时' } });
+        for (const item of testList) {
+          let examId = `${parameter.project}_${item}`;
+          callback({ cmd: 'disconnect_request', exam_id: examId, data: { message: 'WS连接超时' } });
+        }
       }
     }, 20000);
     socket.on('connect', async (e: any) => {
       callback({ cmd: 'mySid', data: { sid: socket.id.replace('/midexam#', '') } });
       if (testList.length > 1) {
-        
         //单WS多区直接执行
         for (const item of testList) {
           await delay(100); // 延时

+ 0 - 6
src/views/train/multiple.vue

@@ -874,12 +874,6 @@ onMounted(() => {
   initSpeech();
   //初始化手势
   initHand();
-  setTimeout(() => {
-    //10秒还在0状态就算超时
-    if (examState.value == 0) {
-      getExit();
-    }
-  }, 10000);
   //刷新关闭
   window.onbeforeunload = function (e) {
     var confirmationMessage = "刷新/关闭页面将会关闭页面,是否确认退出页面?";