Эх сурвалжийг харах

读取本机正在运行的远程控制软件

Michael Wang 6 жил өмнө
parent
commit
e3ddd0b009

+ 9 - 0
public/index.html

@@ -7,6 +7,15 @@
   <meta name="viewport" content="width=device-width,initial-scale=1.0">
   <link rel="icon" href="<%= BASE_URL %>favicon.ico">
   <title>网考学生端</title>
+  <script>
+    // 重命名 Electron 提供的 require 详细请参考:https://www.w3cschool.cn/electronmanual/electronmanual-electron-faq.html
+    if (typeof (require) != "undefined") {
+      window.nodeRequire = require;
+      delete window.require;
+      delete window.exports;
+      delete window.module;
+    }
+  </script>
 </head>
 
 <body>

+ 11 - 0
src/components/FaceRecognition/FaceRecognition.vue

@@ -86,6 +86,17 @@ export default {
       video && video.play();
     },
     async snap() {
+      // TODO: chrome 70. FaceDetector检测人脸
+      // var canvas = document.createElement("canvas");
+      // canvas.width = 220;
+      // canvas.height = 165;
+
+      // var context = canvas.getContext("2d");
+      // context.drawImage(this.$refs.video, 0, 0, 220, 165);
+      // var f = new FaceDetector();
+      // const v = await f.detect(canvas);
+      // console.log(v);
+      // return;
       this.disableSnap = true;
       this.msg = "拍照中...";
       const captureBlob = await this.getSnapShot();

+ 42 - 2
src/features/Login/Login.vue

@@ -35,7 +35,7 @@
               <div v-if="errorInfo !== ''">
                 <i-alert type="error" show-icon>{{errorInfo}}</i-alert>
               </div>
-              <i-button size="large" class="qm-primary-button" long @click="login('loginForm')">登录</i-button>
+              <i-button size="large" class="qm-primary-button" long :disabled="disableLoginBtn" @click="login('loginForm')">登录</i-button>
             </i-form-item>
           </i-form>
         </div>
@@ -82,7 +82,8 @@ export default {
             trigger: "blur"
           }
         ]
-      }
+      },
+      disableLoginBtn: true
     };
   },
   async created() {
@@ -108,10 +109,49 @@ export default {
       this.loginForm.password =
         process.env.NODE_ENV === "production" ? "" : "180613";
     }
+
+    if (typeof nodeRequire != "undefined") {
+      var that = this;
+      var fs = nodeRequire("fs");
+      var config = fs.readFileSync(process.cwd() + "/" + "config.js", "utf-8");
+      var nameJson = JSON.parse(config);
+      const electronConfig = (await this.$http.get(
+        "https://ecs.qmth.com.cn:8878/electron-config/" + nameJson.name + ".js"
+      )).data;
+
+      //如果配置中配置了  checkRomateControl:true
+      if (electronConfig.otherConfig.checkRomateControl) {
+        nodeRequire("node-cmd").get("Project1.exe", function(data) {
+          var applicationNames = fs.readFileSync(
+            "remoteApplication.txt",
+            "utf-8"
+          );
+          if (applicationNames && applicationNames.trim()) {
+            that.disableLoginBtn = true;
+            that.$Message.info({
+              content:
+                "在考试期间,请关掉" +
+                applicationNames.trim() +
+                "软件,诚信考试。",
+              duration: 30
+            });
+          } else {
+            this.disableLoginBtn = false;
+          }
+        });
+      } else {
+        this.disableLoginBtn = false;
+      }
+    } else {
+      this.disableLoginBtn = false;
+    }
   },
   methods: {
     ...mapMutations(["updateUser"]),
     async login(name) {
+      if (this.loginButtonDisabled) {
+        return;
+      }
       const valid = await this.$refs[name].validate();
       if (valid) {
         console.log("form validated. start login...");