소스 검색

客户端版本允许范围后台控制

Michael Wang 5 년 전
부모
커밋
e9a197a447
2개의 변경된 파일60개의 추가작업 그리고 42개의 파일을 삭제
  1. 47 41
      src/features/Login/Login.vue
  2. 13 1
      src/utils/ua.js

+ 47 - 41
src/features/Login/Login.vue

@@ -127,7 +127,7 @@ import { FACE_API_MODEL_PATH } from "@/constants/constants";
 import DevTools from "./DevTools.vue";
 import nativeExe from "@/utils/nativeExe";
 import { EPCC_DOMAIN } from "@/constants/constants";
-import UA, { chromeUA } from "@/utils/ua.js";
+import UA, { isGreatThanEqual200 } from "@/utils/ua.js";
 
 // 检测devtools.  仅在chrome 72+ 有效。
 let element = new Image();
@@ -351,48 +351,28 @@ export default {
         process.env.NODE_ENV === "production" ? "" : "180613";
     }
 
-    if (
-      [
-        "xjtu.ecs.qmth.com.cn",
-        "ccnu.ecs.qmth.com.cn",
-        "snnu.ecs.qmth.com.cn",
-        "swjtu.ecs.qmth.com.cn",
-      ].includes(this.$route.params.domain)
-    ) {
-      if (
-        typeof nodeRequire == "undefined" ||
-        !window.nodeRequire("fs").existsSync("multiCamera.exe")
-      ) {
-        this.disableLoginBtnBecauseAppVersionChecker = true;
-        this.$Message.error({
-          content: "请与学校申请最新的客户端,进行考试!",
-          duration: 2 * 24 * 60 * 60,
-        });
-      }
-    }
-
-    if (
-      [
-        "cup.ecs.qmth.com.cn",
-        "cugr.ecs.qmth.com.cn",
-        "sdu.ecs.qmth.com.cn",
-      ].includes(this.$route.params.domain)
-    ) {
-      // console.log(UA.getBrowser(), chromeUA);
-      if (
-        UA.getBrowser().name !== "electron-exam-shell" ||
-        UA.getBrowser().major !== "2" ||
-        chromeUA.major < "76"
-      ) {
-        this.disableLoginBtnBecauseAppVersionChecker = true;
-        this.$Message.error({
-          content: "请与学校申请最新的客户端,进行考试!",
-          duration: 2 * 24 * 60 * 60,
-        });
-      }
-    }
+    // if (
+    //   [
+    //     "xjtu.ecs.qmth.com.cn",
+    //     "ccnu.ecs.qmth.com.cn",
+    //     "snnu.ecs.qmth.com.cn",
+    //     "swjtu.ecs.qmth.com.cn",
+    //   ].includes(this.$route.params.domain)
+    // ) {
+    //   if (
+    //     typeof nodeRequire == "undefined" ||
+    //     !window.nodeRequire("fs").existsSync("multiCamera.exe")
+    //   ) {
+    //     this.disableLoginBtnBecauseAppVersionChecker = true;
+    //     this.$Message.error({
+    //       content: "请与学校申请最新的客户端,进行考试!",
+    //       duration: 2 * 24 * 60 * 60,
+    //     });
+    //   }
+    // }
 
     await this.checkElectronConfig();
+    await this.checkAppVersion();
     await this.checkVCam();
 
     if (
@@ -757,6 +737,32 @@ export default {
         this.disableLoginBtnBecauseVCam = false;
       }
     },
+    async checkAppVersion() {
+      // console.log(UA.getBrowser(), chromeUA);
+      const allowVer = this.QECSConfig.STUDENT_CLIENT_VERSION.split(",");
+      if (allowVer.includes("1.0.0")) {
+        // 包含 1.0.0 时所有都能进,包括浏览器
+        this.disableLoginBtnBecauseAppVersionChecker = false;
+      } else if (isGreatThanEqual200) {
+        // 判断是否为大于等于 2.0.0 的客户端
+        if (allowVer.includes(UA.getBrowser().version)) {
+          this.disableLoginBtnBecauseAppVersionChecker = false;
+        } else {
+          this.disableLoginBtnBecauseAppVersionChecker = true;
+          this.$Message.error({
+            content: "请与学校申请最新的客户端,进行考试!",
+            duration: 2 * 24 * 60 * 60,
+          });
+        }
+      } else {
+        // 此处表示当不选择1.0.0时,所有非2.0.0单独exe的包都不能进
+        this.disableLoginBtnBecauseAppVersionChecker = true;
+        this.$Message.error({
+          content: "请与学校申请最新的客户端,进行考试!",
+          duration: 2 * 24 * 60 * 60,
+        });
+      }
+    },
     closeApp() {
       window.close();
     },

+ 13 - 1
src/utils/ua.js

@@ -4,17 +4,29 @@ const examShellRegex = [
   [/(electron-exam-shell)\/([\w.]+)/i],
   [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION],
 ];
-export default new UAParser(
+const UA = new UAParser(
   navigator.userAgent,
   // "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) electron-exam-shell/2.0.0 Chrome/77.0.3865.120 Safari/537.36 ",
   { browser: examShellRegex }
 );
 
+export default UA;
+
 export const chromeUA = new UAParser(
   navigator.userAgent.replace("electron-exam-shell/", ""),
   null
 ).getBrowser();
 
+// export const is100 =
+//   UA.getBrowser().name !== "electron-exam-shell" ||
+//   UA.getBrowser().major !== "2" ||
+//   chromeUA.major < "76";
+
+export const isGreatThanEqual200 =
+  UA.getBrowser().name === "electron-exam-shell" &&
+  UA.getBrowser().major >= "2" &&
+  chromeUA.major >= "76";
+
 // const UA = new UAParser(
 //   // null,
 //   "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) electron-exam-shell/2.0.0 Chrome/76.0.3809.139 Electron/6.0.7 Safari/537.36",