浏览代码

控制台打开优化

Michael Wang 5 年之前
父节点
当前提交
6ed149a79b
共有 3 个文件被更改,包括 72 次插入7 次删除
  1. 48 0
      src/features/Login/DevTools.vue
  2. 20 1
      src/features/Login/Login.vue
  3. 4 6
      vue.config.js

+ 48 - 0
src/features/Login/DevTools.vue

@@ -0,0 +1,48 @@
+<template>
+  <div></div>
+</template>
+
+<script>
+export default {
+  name: "DevTools",
+  created() {
+    if (typeof nodeRequire != "undefined") {
+      // 按Ctrl+Shift+U,放开U,在一秒内再按Ctrl+Shift+P,可以调出开发者工具
+      let firstStepKey = false;
+      let secondStepKey = false;
+      let psscode = [];
+      this.listener = document.addEventListener("keydown", function(e) {
+        // console.log(e.code);
+        if (firstStepKey && secondStepKey) {
+          // console.log(psscode);
+          psscode.push(e.code[e.code.length - 1]);
+          // console.log(psscode);
+          if (
+            psscode.join("").toLowerCase() ===
+            window.QECSConfig.STUDENT_CLIENT_CONSOLE_CONFIG
+          ) {
+            window
+              .nodeRequire("electron")
+              .remote.getCurrentWindow()
+              .toggleDevTools();
+          }
+        }
+        if (e.ctrlKey && e.shiftKey && e.code === "KeyU") {
+          firstStepKey = true;
+          setTimeout(() => {
+            firstStepKey = false;
+            secondStepKey = false;
+            psscode = [];
+          }, 5000);
+        }
+        if (firstStepKey && e.ctrlKey && e.shiftKey && e.code === "KeyP") {
+          secondStepKey = true;
+        }
+      });
+    }
+  },
+  beforeDestroy() {
+    if (this.listener) document.removeEventListener(this.listener);
+  },
+};
+</script>

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

@@ -22,6 +22,7 @@
               'qm-big-text',
               'login-type',
               loginType === 'STUDENT_CODE' && 'active-type',
+              allowLoginType.length === 1 && 'single-login-type',
             ]"
             @click="loginType = 'STUDENT_CODE'"
             style="border-top-left-radius: 6px"
@@ -34,12 +35,18 @@
               'qm-big-text',
               'login-type',
               loginType !== 'STUDENT_CODE' && 'active-type',
+              allowLoginType.length === 1 && 'single-login-type',
             ]"
             @click="loginType = 'STUDENT_IDENTITY_NUMBER'"
             style="border-top-right-radius: 6px"
           >
             身份证号登录
           </a>
+          <a
+            v-if="allowLoginType.length === 0"
+            :class="['qm-big-text', 'login-type']"
+            >loading...</a
+          >
         </div>
 
         <div class="qm-title-text" style="margin: 40px 0 20px 0">
@@ -99,6 +106,7 @@
       <div style="position: absolute; right: 20px; bottom: 20px;">
         版本: {{ VUE_APP_GIT_REPO_VERSION }}
       </div>
+      <DevTools />
     </footer>
   </div>
 </template>
@@ -107,6 +115,7 @@
 import moment from "moment";
 import { mapMutations } from "vuex";
 import { FACE_API_MODEL_PATH } from "@/constants/constants";
+import DevTools from "./DevTools.vue";
 /**
  * 在任何组件需要强制退出,做以下步骤
  * 1. this.$Message.info()
@@ -536,7 +545,10 @@ export default {
       return this.QECSConfig.OE_STUDENT_SYS_NAME || "远程教育网络考试";
     },
     allowLoginType() {
-      return this.QECSConfig.LOGIN_TYPE || [];
+      return (
+        (this.QECSConfig.LOGIN_TYPE && this.QECSConfig.LOGIN_TYPE.split(",")) ||
+        []
+      );
     },
     schoolDomain() {
       const domain = this.domainInUrl;
@@ -564,6 +576,9 @@ export default {
       }
     },
   },
+  components: {
+    DevTools,
+  },
 };
 </script>
 
@@ -620,6 +635,10 @@ export default {
 .active-type {
   background-color: #ffffff;
 }
+.single-login-type {
+  border-top-left-radius: 6px;
+  border-top-right-radius: 6px;
+}
 
 .close {
   position: absolute;

+ 4 - 6
vue.config.js

@@ -109,17 +109,15 @@ module.exports = {
         },
         {
           // Match any same-origin request that contains 'api'.
-          // logo 每天更新一次
-          urlPattern: /\/api\/ecs_core\/org\/logo\?domain=/,
+          // logo 地址会变
+          urlPattern: new RegExp(
+            "^https://ecs-test-static.qmth.com.cn/org_logo/.*/.*"
+          ),
           handler: "cacheFirst",
           options: {
             cacheableResponse: {
               statuses: [0, 200],
             },
-            cacheName: "logo-cache",
-            expiration: {
-              maxAgeSeconds: 24 * 60 * 60,
-            },
           },
         },
         {