Răsfoiți Sursa

考试过程中检测远程桌面软件

Michael Wang 5 ani în urmă
părinte
comite
6f5c1335a2
1 a modificat fișierele cu 104 adăugiri și 1 ștergeri
  1. 104 1
      src/features/OnlineExam/Examing/ExamingHome.vue

+ 104 - 1
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -64,6 +64,15 @@
       <p slot="footer"></p>
     </Modal>
     <FaceTracking v-if="faceEnable && startVideoAfterDelay && PRODUCTION" />
+    <div
+      v-if="disableExamingBecauseRemoteApp"
+      style="top:0;left:0;width:100vw;height:100vh;background-color: rgba(77,77,77,0.75);z-index:100;position:absolute;"
+    >
+      <h3 style="margin-top: 80px;">
+        请关闭远程桌面软件再进行考试!
+      </h3>
+      <i-button @click="checkRemoteApp">确认已关闭远程桌面软件</i-button>
+    </div>
   </div>
   <div v-else>
     正在等待数据返回...
@@ -85,8 +94,9 @@ import FaceId from "./FaceId.vue";
 import FaceMotion from "./FaceMotion/FaceMotion";
 import FaceRecognition from "../../../components/FaceRecognition/FaceRecognition";
 import { openWS, closeWsWithoutReconnect } from "./ws.js";
-import { createNamespacedHelpers } from "vuex";
+import { createNamespacedHelpers, mapState as globalMapState } from "vuex";
 const { mapState, mapMutations } = createNamespacedHelpers("examingHomeModule");
+import nativeExe, { fileExists } from "@/utils/nativeExe";
 
 export default {
   name: "ExamingHome",
@@ -110,9 +120,11 @@ export default {
       timeouted: false,
       startVideoAfterDelay: false,
       PRODUCTION: process.env.NODE_ENV === "production",
+      disableExamingBecauseRemoteApp: false,
     };
   },
   computed: {
+    ...globalMapState(["QECSConfig"]),
     ...mapState([
       "exam",
       "paperStruct",
@@ -260,6 +272,11 @@ export default {
       5 * 1000 // 10秒检查是否有更改需要提交答案
     );
 
+    this.checkRemoteAppInterval = setInterval(
+      () => this.checkRemoteApp(),
+      3 * 60 * 1000 // 10秒检查是否有更改需要提交答案
+    );
+
     console.log("考试开始 ", this.$route.params.examRecordDataId);
   },
   async mounted() {
@@ -317,6 +334,7 @@ export default {
     clearTimeout(this.faceIdMsgTimeout);
     clearTimeout(this.faceIdDivTimeout);
     clearTimeout(this.startVideoAfterDelayTimeout);
+    clearInterval(this.checkRemoteAppInterval);
     closeWsWithoutReconnect();
     this.updateExamState({
       exam: null,
@@ -925,6 +943,91 @@ export default {
       this.logger({ page: "答题页面", action: "页面加载失败" });
       window.location.reload();
     },
+    async checkRemoteApp() {
+      if (typeof nodeRequire == "undefined") {
+        return;
+      }
+
+      async function checkRemoteAppTxt() {
+        let applicationNames;
+        try {
+          const fs = window.nodeRequire("fs");
+          try {
+            applicationNames = fs.readFileSync(
+              "remoteApplication.txt",
+              "utf-8"
+            );
+          } catch (error) {
+            console.log(error);
+            window._hmt.push([
+              "_trackEvent",
+              "答题页面",
+              "读取remoteApplication.txt出错--0",
+            ]);
+            await new Promise(resolve2 => setTimeout(() => resolve2(), 3000));
+            applicationNames = fs.readFileSync(
+              "remoteApplication.txt",
+              "utf-8"
+            );
+          }
+        } catch (error) {
+          console.log(error);
+          // this.logger({
+          //   currentPage: "答题页面",
+          //   errorType: "e-01",
+          //   error: error.message,
+          //   detail: applicationNames,
+          // });
+          window._hmt.push([
+            "_trackEvent",
+            "答题页面",
+            "读取remoteApplication.txt出错",
+          ]);
+          // this.$Message.error({
+          //   content: "系统检测出错(e-01),请退出程序后重试!",
+          //   duration: 2 * 24 * 60 * 60,
+          // });
+          return;
+        }
+        if (applicationNames && applicationNames.trim()) {
+          let names = applicationNames
+            .replace("qq", "QQ")
+            .replace("teamviewer", "TeamViewer")
+            .replace("lookmypc", "LookMyPC")
+            .replace("xt", "协通")
+            .replace("winaw32", "Symantec PCAnywhere")
+            .replace("pcaquickconnect", "Symantec PCAnywhere")
+            .replace("sessioncontroller", "Symantec PCAnywhere")
+            .replace(/sunloginclient/gi, "向日葵")
+            .replace("wemeetapp", "腾讯会议");
+
+          names = [...new Set(names.split(",").map(v => v.trim()))].join(",");
+          this.disableExamingBecauseRemoteApp = true;
+          this.$Message.info({
+            content: "在考试期间,请关掉" + names + "软件,诚信考试。",
+            duration: 30,
+          });
+        } else {
+          this.disableExamingBecauseRemoteApp = false;
+        }
+      }
+      //如果配置中配置了 DISABLE_REMOTE_ASSISTANCE
+      if (
+        this.QECSConfig.PREVENT_CHEATING_CONFIG.includes(
+          "DISABLE_REMOTE_ASSISTANCE"
+        )
+      ) {
+        let exe = "Project1.exe";
+        if (fileExists("Project2.exe")) {
+          const remoteAppName =
+            "qq;teamviewer;lookmypc;xt;winaw32;pcaquickconnect;sessioncontroller;sunloginclient;wemeetapp";
+          exe = `Project2.exe "${remoteAppName}" `;
+        }
+        await nativeExe(exe, checkRemoteAppTxt.bind(this));
+      } else {
+        this.disableExamingBecauseRemoteApp = false;
+      }
+    },
   },
 };
 </script>