Преглед на файлове

采用Project2.exe检测远程桌面软件

Michael Wang преди 5 години
родител
ревизия
40045fd926
променени са 2 файла, в които са добавени 66 реда и са изтрити 10 реда
  1. 53 10
      src/features/Login/Login.vue
  2. 13 0
      src/utils/nativeExe.js

+ 53 - 10
src/features/Login/Login.vue

@@ -125,7 +125,7 @@ import moment from "moment";
 import { mapMutations } from "vuex";
 import { FACE_API_MODEL_PATH } from "@/constants/constants";
 import DevTools from "./DevTools.vue";
-import nativeExe from "@/utils/nativeExe";
+import nativeExe, { fileExists } from "@/utils/nativeExe";
 import {
   EPCC_DOMAIN,
   VUE_APP_CONFIG_FILE_SEVER_URL,
@@ -683,11 +683,28 @@ export default {
         return;
       }
 
-      function checkRemoteAppTxt() {
+      async function checkRemoteAppTxt() {
         let applicationNames;
         try {
           const fs = window.nodeRequire("fs");
-          applicationNames = fs.readFileSync("remoteApplication.txt", "utf-8");
+          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);
           window._hmt.push([
@@ -702,12 +719,21 @@ export default {
           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", "向日葵")
+            .replace("wemeet", "腾讯会议");
+
+          names = [...new Set(names.split(","))].join("");
           this.disableLoginBtnBecauseRemoteApp = true;
           this.$Message.info({
-            content:
-              "在考试期间,请关掉" +
-              applicationNames.trim() +
-              "软件,诚信考试。",
+            content: "在考试期间,请关掉" + names + "软件,诚信考试。",
             duration: 2 * 24 * 60 * 60,
           });
         } else {
@@ -720,7 +746,13 @@ export default {
           "DISABLE_REMOTE_ASSISTANCE"
         )
       ) {
-        await nativeExe("Project1.exe", checkRemoteAppTxt.bind(this));
+        let exe = "Project1.exe";
+        if (fileExists("Project2.exe")) {
+          const remoteAppName =
+            "qq;teamviewer;lookmypc;xt;winaw32;pcaquickconnect;sessioncontroller;sunloginclient;wemeet";
+          exe = `Project2.exe "${remoteAppName}" `;
+        }
+        await nativeExe(exe, checkRemoteAppTxt.bind(this));
       } else {
         this.disableLoginBtnBecauseRemoteApp = false;
       }
@@ -761,11 +793,22 @@ export default {
         "魔力秀",
       ];
 
-      function checkVCamTxt() {
+      async function checkVCamTxt() {
         let applicationNames;
         try {
           const fs = window.nodeRequire("fs");
-          applicationNames = fs.readFileSync("CameraInfo.txt", "utf-8");
+          try {
+            applicationNames = fs.readFileSync("CameraInfo.txt", "utf-8");
+          } catch (error) {
+            console.log(error);
+            window._hmt.push([
+              "_trackEvent",
+              "登录页面",
+              "CameraInfo.txt出错--0",
+            ]);
+            await new Promise(resolve2 => setTimeout(() => resolve2(), 3000));
+            applicationNames = fs.readFileSync("CameraInfo.txt", "utf-8");
+          }
         } catch (error) {
           console.log(error);
           window._hmt.push([

+ 13 - 0
src/utils/nativeExe.js

@@ -17,3 +17,16 @@ export default function async(exeName, cb) {
     });
   });
 }
+
+export function fileExists(file) {
+  if (typeof nodeRequire == "undefined") {
+    console.log("nodeRequire failed");
+    window._hmt.push([
+      "_trackEvent",
+      window.location.pathname.replace(/\d+/g, ""),
+      "不在Electron中,调用 fs 失败",
+    ]);
+    throw "不在Electron中,调用 fs 失败";
+  }
+  return window.nodeRequire("fs").existsSync(file);
+}