Michael Wang 3 rokov pred
rodič
commit
d2bfba78b2

+ 7 - 0
src/constants/constants.js

@@ -42,3 +42,10 @@ if (!domain) domain = window.location.hostname.split(".")[0];
 export const DOMAIN_IN_URL = domain + ".ecs.qmth.com.cn";
 
 export const PRIVACY_READ_VERSION_NUMBER = "1";
+
+export const fileHashMap = new Map([
+  [
+    "qmtest.exam-cloud.cn",
+    "a31c9eb84fe82031fb01e9e25262f0b407caa705b5245654faeed1490bff67f9",
+  ],
+]);

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

@@ -446,7 +446,15 @@ export default {
       });
     }
     registerOnResize();
-    checkMainExe();
+    if (UA.getBrowser().version > "1.9.2") {
+      if (!checkMainExe()) {
+        this.disableLoginBtnBecauseAppVersionChecker = true;
+        this.$Message.error({
+          content: "请与学校申请最新的客户端,进行考试!",
+          duration: 2 * 24 * 60 * 60,
+        });
+      }
+    }
 
     if (
       [

+ 5 - 0
src/utils/util.js

@@ -1,3 +1,4 @@
+import { fileHashMap } from "@/constants/constants";
 import { throttle } from "lodash";
 import { createLog } from "./logger";
 
@@ -106,9 +107,13 @@ export function checkMainExe() {
         .update(window.nodeRequire("fs").readFileSync(executablePath))
         .digest("hex");
       console.log("the hash: ", getHash);
+      if (fileHashMap.get(window.location.hostname) === getHash) {
+        return true;
+      }
     }
     // check filepath executablePath md5
   } catch (error) {
     console.log(error);
   }
+  return false;
 }