刘洋 1 жил өмнө
parent
commit
aa154c4368

+ 7 - 2
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -225,7 +225,8 @@ addTimeout(() => {
 
 const {
   disableLoginBtnBecauseRemoteApp: disableExamingBecauseRemoteApp,
-  checkRemoteAppTxt: checkRemoteApp,
+  // checkRemoteAppTxt: checkRemoteApp,
+  checkBlackAppLoopMethod: checkRemoteApp,
 } = useRemoteAppChecker();
 
 function checkRemoteAppClicked() {
@@ -234,7 +235,11 @@ function checkRemoteAppClicked() {
 }
 
 // 3分钟检测是否有远程桌面软件在运行
-addInterval(() => checkRemoteApp(), 3 * 60 * 1000);
+if (
+  store.QECSConfig.PREVENT_CHEATING_CONFIG?.includes("EXAMING_BLACK_LIST_CHECK")
+) {
+  addInterval(() => checkRemoteApp(), 3 * 60 * 1000);
+}
 //#endregion 防作弊检查
 
 const userInfo = $computed(() => {

+ 86 - 38
src/features/UserLogin/useRemoteAppChecker.tsx

@@ -123,6 +123,52 @@ export function useRemoteAppChecker() {
   let disableLoginBtnBecauseRemoteApp = $ref(true);
 
   const QECSConfig = $computed(() => store.QECSConfig);
+
+
+  async function checkBlackAppLoopMethod(){
+    if (import.meta.env.DEV) {
+      disableLoginBtnBecauseRemoteApp = false;
+      return;
+    }
+    if (
+      !QECSConfig.PREVENT_CHEATING_CONFIG?.includes(
+        "DISABLE_REMOTE_ASSISTANCE"
+      )
+    ) {
+      disableLoginBtnBecauseRemoteApp = false;
+      return;
+    }
+
+    let exe = "Project1.exe";
+    try {
+      if (fileExists("Project2.exe")) {
+        const { remoteApp: remoteAppName } = await getBlackAppConfig();
+        console.log('remoteAppName:',remoteAppName)
+        exe = `Project2.exe "${remoteAppName}" `;
+      }
+
+      const fs: typeof import("fs") = window.nodeRequire("fs");
+      fileExists("remoteApplication.txt") &&
+        fs.unlinkSync("remoteApplication.txt");
+    } catch (error) {
+      console.log(error);
+      logger({
+        cnl: ["local", "server"],
+        pgu: "AUTO",
+        key: "checkRemoteAppTxt",
+        dtl: "unlink remoteApplication.txt 失败",
+        possibleError: error,
+      });
+      $message.error("请关闭远程控制程序后重试", {
+        duration: 24 * 60 * 60 * 1000,
+      });
+      throw error;
+    }
+    await execLocal(exe);
+
+    await checkRemoteAppTxt();
+  }
+
   watch(
     () => QECSConfig.PREVENT_CHEATING_CONFIG,
     async (val, oldVal) => {
@@ -130,47 +176,48 @@ export function useRemoteAppChecker() {
       // 同时,还通过网络获取,所以此时的监听会发生两次,两次可能导致 remoteApplication.txt 被删除后读取不到
       // 所以此时发现值一样就不要进行后续
       if (JSON.stringify(val) === JSON.stringify(oldVal)) return;
-      if (import.meta.env.DEV) {
-        disableLoginBtnBecauseRemoteApp = false;
-        return;
-      }
-      if (
-        !QECSConfig.PREVENT_CHEATING_CONFIG?.includes(
-          "DISABLE_REMOTE_ASSISTANCE"
-        )
-      ) {
-        disableLoginBtnBecauseRemoteApp = false;
-        return;
-      }
+      await checkBlackAppLoopMethod();
+      // if (import.meta.env.DEV) {
+      //   disableLoginBtnBecauseRemoteApp = false;
+      //   return;
+      // }
+      // if (
+      //   !QECSConfig.PREVENT_CHEATING_CONFIG?.includes(
+      //     "DISABLE_REMOTE_ASSISTANCE"
+      //   )
+      // ) {
+      //   disableLoginBtnBecauseRemoteApp = false;
+      //   return;
+      // }
 
-      let exe = "Project1.exe";
-      try {
-        if (fileExists("Project2.exe")) {
-          const { remoteApp: remoteAppName } = await getBlackAppConfig();
-          console.log('remoteAppName:',remoteAppName)
-          exe = `Project2.exe "${remoteAppName}" `;
-        }
+      // let exe = "Project1.exe";
+      // try {
+      //   if (fileExists("Project2.exe")) {
+      //     const { remoteApp: remoteAppName } = await getBlackAppConfig();
+      //     console.log('remoteAppName:',remoteAppName)
+      //     exe = `Project2.exe "${remoteAppName}" `;
+      //   }
 
-        const fs: typeof import("fs") = window.nodeRequire("fs");
-        fileExists("remoteApplication.txt") &&
-          fs.unlinkSync("remoteApplication.txt");
-      } catch (error) {
-        console.log(error);
-        logger({
-          cnl: ["local", "server"],
-          pgu: "AUTO",
-          key: "checkRemoteAppTxt",
-          dtl: "unlink remoteApplication.txt 失败",
-          possibleError: error,
-        });
-        $message.error("请关闭远程控制程序后重试", {
-          duration: 24 * 60 * 60 * 1000,
-        });
-        throw error;
-      }
-      await execLocal(exe);
+      //   const fs: typeof import("fs") = window.nodeRequire("fs");
+      //   fileExists("remoteApplication.txt") &&
+      //     fs.unlinkSync("remoteApplication.txt");
+      // } catch (error) {
+      //   console.log(error);
+      //   logger({
+      //     cnl: ["local", "server"],
+      //     pgu: "AUTO",
+      //     key: "checkRemoteAppTxt",
+      //     dtl: "unlink remoteApplication.txt 失败",
+      //     possibleError: error,
+      //   });
+      //   $message.error("请关闭远程控制程序后重试", {
+      //     duration: 24 * 60 * 60 * 1000,
+      //   });
+      //   throw error;
+      // }
+      // await execLocal(exe);
 
-      await checkRemoteAppTxt();
+      // await checkRemoteAppTxt();
     },
     { immediate: true }
   );
@@ -178,5 +225,6 @@ export function useRemoteAppChecker() {
   return {
     disableLoginBtnBecauseRemoteApp: $$(disableLoginBtnBecauseRemoteApp),
     checkRemoteAppTxt,
+    checkBlackAppLoopMethod
   };
 }

+ 2 - 1
src/types/student-client.d.ts

@@ -44,7 +44,8 @@ export type Store = {
         "DISABLE_REMOTE_ASSISTANCE",
         "DISABLE_VIRTUAL_CAMERA",
         "DISABLE_MULTISCREEN",
-        "RECORD_SWITCH_SCREEN"
+        "RECORD_SWITCH_SCREEN",
+        "EXAMING_BLACK_LIST_CHECK"
       ]
     >;
     /** 学校是否有定制logo !!!需对json进行转换!!! */