소스 검색

启动依赖版本管理 登录验证码是否需要校验

xgb 1 일 전
부모
커밋
d527851084
3개의 변경된 파일28개의 추가작업 그리고 9개의 파일을 삭제
  1. 3 1
      package.json
  2. 2 1
      src/main.js
  3. 23 7
      src/views/login/index.vue

+ 3 - 1
package.json

@@ -37,7 +37,9 @@
     "element-ui": "2.15.5",
     "js-cookie": "2.2.1",
     "nprogress": "0.2.0",
+    "screenfull": "5.2.0",
     "vue": "2.6.12",
+    "vue-meta": "2.4.0",
     "vue-router": "3.4.9",
     "vuex": "3.6.0"
   },
@@ -68,4 +70,4 @@
     "> 1%",
     "last 2 versions"
   ]
-}
+}

+ 2 - 1
src/main.js

@@ -17,9 +17,10 @@ import router from './router'
 import './permission' // permission control
 import VueMeta from 'vue-meta'
 import * as echarts from "echarts";
+import logImgDefault from '@/assets/images/profile.jpg'
 
 // 全局方法挂载
-Vue.prototype.logImg = require(process.env.VUE_APP_LOG_URL || '@/assets/images/profile.jpg')
+Vue.prototype.logImg = process.env.VUE_APP_LOG_URL || logImgDefault
 Vue.prototype.echarts = echarts
 
 Vue.prototype.msgSuccess = function (msg) {

+ 23 - 7
src/views/login/index.vue

@@ -12,10 +12,10 @@
         <el-form-item label="密码" prop="password">
           <el-input type="password" v-model="loginForm.password" placeholder="请输入密码" show-password />
         </el-form-item>
-        <el-form-item label="验证码" prop="code">
+        <el-form-item label="验证码" prop="code" v-if="captchaOnOff">
           <div style="display:flex;align-items:center;">
             <el-input v-model="loginForm.code" placeholder="请输入验证码" style="flex:1" @keyup.enter.native="handleLogin" />
-            <img :src="codeUrl" @click="getCode" class="code-img" title="点击刷新" />
+            <img v-if="codeUrl" :src="codeUrl" @click="getCode" class="code-img" title="点击刷新" />
           </div>
         </el-form-item>
         <el-form-item>
@@ -35,6 +35,7 @@ export default {
     return {
       loading: false,
       codeUrl: '',
+      captchaOnOff: true,
       loginForm: {
         username: '',
         password: '',
@@ -54,8 +55,11 @@ export default {
   methods: {
     getCode() {
       getCodeImg().then(res => {
-        this.codeUrl = "data:image/gif;base64," + res.img
-        this.loginForm.uuid = res.uuid
+        this.captchaOnOff = res.captchaOnOff === undefined ? true : res.captchaOnOff
+        if (this.captchaOnOff) {
+          this.codeUrl = "data:image/gif;base64," + res.img
+          this.loginForm.uuid = res.uuid
+        }
       }).catch(() => {
         this.codeUrl = ''
       })
@@ -65,7 +69,15 @@ export default {
         if (!valid) return
         this.loading = true
         try {
-          const response = await login(this.loginForm)
+          const data = {
+            username: this.loginForm.username,
+            password: this.loginForm.password
+          }
+          if (this.captchaOnOff) {
+            data.code = this.loginForm.code
+            data.uuid = this.loginForm.uuid
+          }
+          const response = await login(data)
           if (response.code === 200) {
             this.$store.dispatch('setToken', response.token)
             if (response.proxyInfo) {
@@ -74,11 +86,15 @@ export default {
             this.$router.push('/dashboard')
           } else {
             this.$message.error(response.msg || '登录失败')
-            this.getCode()
+            if (this.captchaOnOff) {
+              this.getCode()
+            }
           }
         } catch (error) {
           this.$message.error('登录失败')
-          this.getCode()
+          if (this.captchaOnOff) {
+            this.getCode()
+          }
         } finally {
           this.loading = false
         }