Ver Fonte

登录页加入防连击

xusl há 2 anos atrás
pai
commit
8894a97254
1 ficheiros alterados com 7 adições e 8 exclusões
  1. 7 8
      ui/src/views/login/index.vue

+ 7 - 8
ui/src/views/login/index.vue

@@ -83,6 +83,7 @@
 
 
 import store from "@/store";
 import store from "@/store";
 import {doEncrypt, doSign} from "@/utils/smutil";
 import {doEncrypt, doSign} from "@/utils/smutil";
+import {debounce} from "lodash";
 
 
 export default {
 export default {
   name: 'Login',
   name: 'Login',
@@ -197,7 +198,7 @@ export default {
     /**
     /**
      * 发送邮箱验证码
      * 发送邮箱验证码
      */
      */
-    sendMailCode() {
+    sendMailCode:debounce(function(){
       // 判断账户是否已经输入
       // 判断账户是否已经输入
       if (!this.loginForm.username) {
       if (!this.loginForm.username) {
         this.$message.error('请输入账号')
         this.$message.error('请输入账号')
@@ -216,22 +217,20 @@ export default {
       ).then((res) => {
       ).then((res) => {
         this.$message.success('邮件发送成功')
         this.$message.success('邮件发送成功')
       })
       })
-    },
+    },1000),
     // 获取验证码
     // 获取验证码
-    getCaptcha() {
-      // this.$axios.get('/sysFile/getFileContent',{params:{"path":path,"name":name}}).then
-
+    getCaptcha:debounce(function(){
       this.$axios.get('/getVerifyCode').then((res) => {
       this.$axios.get('/getVerifyCode').then((res) => {
         this.verifyuuid = res.data.uuid
         this.verifyuuid = res.data.uuid
         this.captchaUrl = 'data:image/gif;base64,' + res.data.imgBase64;
         this.captchaUrl = 'data:image/gif;base64,' + res.data.imgBase64;
         this.captchaText = res.data.captchaText
         this.captchaText = res.data.captchaText
       })
       })
-    },
+    },1000),
     updateCaptcha() {
     updateCaptcha() {
       // 更新验证码
       // 更新验证码
       this.getCaptcha()
       this.getCaptcha()
     },
     },
-    handleLogin() {
+    handleLogin:debounce(function(){
       this.$refs.loginForm.validate(valid => {
       this.$refs.loginForm.validate(valid => {
         if (valid) {
         if (valid) {
           this.loading = true
           this.loading = true
@@ -276,7 +275,7 @@ export default {
           return false
           return false
         }
         }
       })
       })
-    }
+    },1000)
   }
   }
 }
 }
 </script>
 </script>