zhangjie před 4 roky
rodič
revize
cc930e1ff3
2 změnil soubory, kde provedl 72 přidání a 2 odebrání
  1. 8 0
      src/assets/styles/login.less
  2. 64 2
      src/views/Login.vue

+ 8 - 0
src/assets/styles/login.less

@@ -61,6 +61,14 @@
     margin-top: 60px;
   }
 
+  &-tips {
+    position: absolute;
+    width: 100%;
+    text-align: center;
+    color: #fff;
+    bottom: 10px;
+  }
+
   .ivu-form-item {
     margin-bottom: 30px;
   }

+ 64 - 2
src/views/Login.vue

@@ -42,7 +42,7 @@
             <Button
               size="large"
               type="primary"
-              :disabled="isSubmit"
+              :disabled="isSubmit || !encryptValid"
               @click="submit"
               style="width: 120px"
               >登录</Button
@@ -51,6 +51,8 @@
         </Form>
       </div>
     </div>
+
+    <div class="login-tips" v-if="tips">{{ tips }}</div>
   </div>
 </template>
 
@@ -59,6 +61,7 @@ import { username, password } from "@/plugins/formRules";
 import initStoreMixin from "../mixins/initStoreMixin";
 import { formatDate } from "../plugins/utils";
 import { $get } from "@/plugins/axios";
+import { mapState, mapActions } from "vuex";
 const { ipcRenderer } = require("electron");
 
 export default {
@@ -74,14 +77,32 @@ export default {
         loginname: username,
         password
       },
-      isSubmit: false
+      isSubmit: false,
+      encryptValid: false,
+      loading: false,
+      tips: "",
+      exceptionIsConfirm: true
     };
   },
+  computed: {
+    ...mapState("client", ["encryptResult"])
+  },
+  watch: {
+    encryptResult(val, oldval) {
+      if (val.success) {
+        this.encryptSuccess();
+      } else {
+        this.encryptError(val);
+      }
+    }
+  },
   mounted() {
     this.$ls.clear();
     this.initData();
+    this.tocCheckEncrypt();
   },
   methods: {
+    ...mapActions("client", ["checkEncrypt"]),
     minWin() {
       ipcRenderer.send("minimize-window");
     },
@@ -134,6 +155,47 @@ export default {
       // this.$router.push({
       //   name: "PaperExport"
       // });
+    },
+    tocCheckEncrypt() {
+      this.exceptionIsConfirm = true;
+      this.loading = true;
+      this.tips = "正在检测加密狗,请稍后……";
+      this.checkEncrypt();
+    },
+    encryptSuccess() {
+      if (!this.exceptionIsConfirm) return;
+      this.exceptionIsConfirm = false;
+
+      this.loading = false;
+      this.tips = "";
+      this.encryptValid = true;
+      this.$Modal.success({
+        content: "加密狗检测成功!",
+        onOk: () => {
+          this.exceptionIsConfirm = true;
+        }
+      });
+    },
+    encryptError(error) {
+      if (!this.exceptionIsConfirm) return;
+      this.exceptionIsConfirm = false;
+
+      this.loading = false;
+      this.encryptValid = false;
+      this.tips = "校验失败!";
+      this.$Modal.confirm({
+        content: error.msg,
+        okText: "关闭程序",
+        cancelText: "重新检测",
+        onOk: () => {
+          ipcRenderer.send("close-window");
+        },
+        onCancel: () => {
+          setTimeout(() => {
+            this.tocCheckEncrypt();
+          });
+        }
+      });
     }
   }
 };