linxuxiang 2 mesiacov pred
rodič
commit
d7cb5f8350
1 zmenil súbory, kde vykonal 31 pridanie a 39 odobranie
  1. 31 39
      src/utils/trainWs.ts

+ 31 - 39
src/utils/trainWs.ts

@@ -593,11 +593,13 @@ export function useWs() {
   /**
    * 退出
    */
-  function getExit(data?: any) {
+  function getExit() {
     //关闭遮罩层
     loading?.close();
+    //清除计时器
+    getClearTimer();
     //通知工作站关闭
-    if (testList.length > 1 && !data) {
+    if (testList.length > 1) {
       //单WS多区
       examStateList.forEach((item: any) => {
         let examId = item.examId;
@@ -606,27 +608,17 @@ export function useWs() {
           class_id: parameter.classes
         });
       });
-      //清除计时器
-      getClearTimer();
-      //如果正在连接就关闭
-      if (socket?.connected) {
-        socket?.close();
-      }
     } else {
       //单WS单区
-      let examId = data ? data : parameter.examId;
+      let examId = parameter.examId;
       sendMessage('exam_ends', {
         data: 'end_' + examId,
         class_id: parameter.classes
       });
-      if (!data) {
-        //清除计时器
-        getClearTimer();
-        //如果正在连接就关闭
-        if (socket?.connected) {
-          socket?.close();
-        }
-      }
+    }
+    //如果正在连接就关闭
+    if (socket?.connected) {
+      socket?.close();
     }
   }
 
@@ -647,28 +639,28 @@ export function useWs() {
    * 清空状态更新定时任务
    */
   function getClearExamStateTimer() {
-		for(let i = 0;i<examStateList.length;i++){
-			if (examStateList[i].hasOwnProperty('timer1')) {
-				clearInterval(examStateList[i].timer1);
-				examStateList[i].timer1 = null;
-			}
-			if (examStateList[i].hasOwnProperty('timer2')) {
-				clearInterval(examStateList[i].timer2);
-				examStateList[i].timer2 = null;
-			}
-			if (examStateList[i].hasOwnProperty('timer3')) {
-				clearInterval(examStateList[i].timer3);
-				examStateList[i].timer3 = null;
-			}
-			if (examStateList[i].hasOwnProperty('timer4')) {
-				clearInterval(examStateList[i].timer4);
-				examStateList[i].timer4 = null;
-			}
-			if (examStateList[i].hasOwnProperty('timer5')) {
-				clearInterval(examStateList[i].timer5);
-				examStateList[i].timer5 = null;
-			}
-		}
+    for (let i = 0; i < examStateList.length; i++) {
+      if (examStateList[i].hasOwnProperty('timer1')) {
+        clearInterval(examStateList[i].timer1);
+        examStateList[i].timer1 = null;
+      }
+      if (examStateList[i].hasOwnProperty('timer2')) {
+        clearInterval(examStateList[i].timer2);
+        examStateList[i].timer2 = null;
+      }
+      if (examStateList[i].hasOwnProperty('timer3')) {
+        clearInterval(examStateList[i].timer3);
+        examStateList[i].timer3 = null;
+      }
+      if (examStateList[i].hasOwnProperty('timer4')) {
+        clearInterval(examStateList[i].timer4);
+        examStateList[i].timer4 = null;
+      }
+      if (examStateList[i].hasOwnProperty('timer5')) {
+        clearInterval(examStateList[i].timer5);
+        examStateList[i].timer5 = null;
+      }
+    }
   }
 
   /**