Michael Wang 4 жил өмнө
parent
commit
fc5825d614

+ 14 - 1
src/features/Login/Login.vue

@@ -135,7 +135,10 @@ import {
 } from "@/constants/constants";
 import { REMOTE_APP_NAME, VCAM_LIST } from "@/constants/constant-namelist";
 import DevTools from "./DevTools.vue";
-import nativeExe, { fileExists } from "@/utils/nativeExe";
+import nativeExe, {
+  fileExists,
+  nodeCheckRemoteDesktop,
+} from "@/utils/nativeExe";
 import UA, { chromeUA } from "@/utils/ua.js";
 import {
   createLog,
@@ -904,6 +907,16 @@ export default {
           });
           return;
         }
+        if (typeof nodeRequire !== "undefined") {
+          const hasSun = nodeCheckRemoteDesktop();
+          if (hasSun) {
+            if (applicationNames) {
+              applicationNames += ",sunloginclient";
+            } else {
+              applicationNames = "sunloginclient";
+            }
+          }
+        }
         if (applicationNames && applicationNames.trim()) {
           let names = applicationNames
             .replace("qq", "QQ")

+ 11 - 0
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -1001,6 +1001,17 @@ export default {
           // });
           return;
         }
+        // 为避免考试过程中卡顿,不在考试过程中同步检测远程桌面软件
+        // if (typeof nodeRequire !== "undefined") {
+        //   const hasSun = nodeCheckRemoteDesktop();
+        //   if (hasSun) {
+        //     if (applicationNames) {
+        //       applicationNames += ",sunloginclient";
+        //     } else {
+        //       applicationNames = "sunloginclient";
+        //     }
+        //   }
+        // }
         if (applicationNames && applicationNames.trim()) {
           let names = applicationNames
             .replace("qq", "QQ")

+ 27 - 5
src/utils/nativeExe.js

@@ -1,6 +1,6 @@
 import { createLog } from "@/utils/logger";
 
-export default function async(exeName, cb) {
+export default function checkRemote(exeName, cb) {
   if (typeof nodeRequire == "undefined") {
     console.log("nodeRequire failed");
     window._hmt.push([
@@ -35,7 +35,7 @@ export default function async(exeName, cb) {
         absPath: exeName.includes(":"),
       });
       // 如果相对路径没找到,则通过绝对路径来执行
-      if (!exeName.includes(":")) {
+      if (!exeName.includes(":") && err) {
         const fs = window.nodeRequire("electron").remote.require("fs");
 
         const path = window.nodeRequire("electron").remote.require("path");
@@ -48,15 +48,20 @@ export default function async(exeName, cb) {
         );
         if (fs.existsSync(absPath)) {
           try {
-            await async([absPath, exeParams].join(" ").trim());
+            await checkRemote([absPath, exeParams].join(" ").trim(), cb);
           } catch (error) {
             console.log("second try error", absPath);
           }
         }
       }
       await new Promise((resolve2) => setTimeout(() => resolve2(), 1000));
-      await cb();
-      resolve();
+      try {
+        await cb();
+      } catch (e) {
+        console.log("call cb failed", e);
+      } finally {
+        resolve();
+      }
     });
   });
 }
@@ -77,3 +82,20 @@ export function fileExists(file) {
   }
   return window.nodeRequire("fs").existsSync(file);
 }
+
+export function nodeCheckRemoteDesktop() {
+  createLog({
+    page: window.location.pathname,
+    action: "nodeCheckRemoteDesktop",
+  });
+
+  const appList = window
+    .nodeRequire("child_process")
+    .execSync("tasklist")
+    .toString();
+  if (appList && appList.match(/sunloginclient/gi).length > 0) {
+    return true;
+  } else {
+    return false;
+  }
+}