Browse Source

标记学习中心电脑,方便以后获取硬件能力信息

Michael Wang 5 years ago
parent
commit
7ee271cc7a

+ 7 - 0
src/features/Login/Login.vue

@@ -537,6 +537,13 @@ export default {
           }
           this.$router.push("/online-exam");
           window._hmt.push(["_trackEvent", "登录页面", "登录成功"]);
+          let userIds = JSON.parse(localStorage.getItem("userIds"));
+          userIds = [...new Set(userIds).add(user.id)];
+          localStorage.setItem("userIds", JSON.stringify(userIds));
+
+          // 学习中心机器
+          // (JSON.parse(localStorage.getItem("userIds")) || []).length > 5;
+
           this.$Spin.hide();
         } catch (error) {
           window._hmt.push([

+ 3 - 1
src/features/OnlineExam/Examing/FaceTracking.vue

@@ -6,6 +6,7 @@
 import * as faceapi from "face-api.js";
 import { FACE_API_MODEL_PATH } from "@/constants/constants";
 import { mapGetters as globalMapGetters } from "vuex";
+import { isThisMachineOwnByStudent } from "@/utils/util";
 
 window.faceapi = faceapi;
 
@@ -180,7 +181,8 @@ export default {
         window._hmt.push([
           "_trackEvent",
           "正在考试页面",
-          "实时人脸检测平均时长",
+          "实时人脸检测平均时长" +
+            (isThisMachineOwnByStudent() ? "学生电脑" : "学习中心电脑"),
           roundAvg + "ms",
         ]);
         console.log(detectTimeArray);

+ 5 - 0
src/utils/util.js

@@ -18,3 +18,8 @@ export function toChineseNumber(num) {
 
   return ret;
 }
+
+// 如果这台机器上登录过的学生人数小于5,那么这台电脑就是学生的
+export function isThisMachineOwnByStudent() {
+  return (JSON.parse(localStorage.getItem("userIds")) || []).length < 5;
+}