ソースを参照

update Login.vue

reghao 3 ヶ月 前
コミット
52049e4084
3 ファイル変更13 行追加23 行削除
  1. 9 5
      src/assets/js/mixin.js
  2. 1 12
      src/views/Login.vue
  3. 3 6
      src/views/admin/Dashboard.vue

+ 9 - 5
src/assets/js/mixin.js

@@ -10,6 +10,7 @@ import store from '@/store'
 export const userMixin = {
   data() {
     return {
+      devops: false,
       pubkey: '',
       pubkeyR: '',
       captchaCode: '',
@@ -160,16 +161,19 @@ export const userMixin = {
     },
     loginBtn() {
       if (this.userLogin.principal === '' || this.userLogin.principal === null) {
-        this.$message.warning('手机号不能为空')
+        this.$message.warning('号不能为空')
         return
       }
       if (this.userLogin.credential === '' || this.userLogin.credential === null) {
-        this.$message.warning('短信验证码不能为空')
+        this.$message.warning('码不能为空')
         return
       }
-      if (this.userLogin.captchaCode === '' || this.userLogin.captchaCode === null) {
-        this.$message.warning('图形验证码不能为空')
-        return
+
+      if (!this.devops) {
+        if (this.userLogin.captchaCode === '' || this.userLogin.captchaCode === null) {
+          this.$message.warning('图形验证码不能为空')
+          return
+        }
       }
 
       const credential = this.userLogin.credential

+ 1 - 12
src/views/Login.vue

@@ -16,7 +16,7 @@
                       <el-form-item label="帐号">
                         <el-input
                           v-model="userLogin.principal"
-                          placeholder="请输入手机号或邮箱"
+                          placeholder="请输入帐号"
                           style="padding-right: 1px"
                           clearable
                         />
@@ -30,16 +30,6 @@
                           clearable
                         />
                       </el-form-item>
-                      <el-form-item label="图形验证码" label-width="90px">
-                        <el-image :src="captchaCode" @click="getCaptcha" />
-                        <el-input
-                          v-model="userLogin.captchaCode"
-                          placeholder="请输入图形验证码"
-                          style="width: 50%; padding-right: 1px"
-                          clearable
-                          @keyup.enter.native="loginBtn"
-                        />
-                      </el-form-item>
                       <el-form-item>
                         <el-button type="primary" size="mini" :loading="isLoading" @click.native="loginBtn">登 入</el-button>
                         <el-button type="plain" size="mini" @click="forgot">忘记密码</el-button>
@@ -160,7 +150,6 @@ export default {
   mixins: [userMixin],
   data() {
     return {
-      devops: false,
       activeName: 'login1'
     }
   },

+ 3 - 6
src/views/admin/Dashboard.vue

@@ -107,15 +107,14 @@
 </template>
 
 <script>
-import store from '@/store'
+import { userMixin } from 'assets/js/mixin'
 import { getDashboard } from '@/api/devops'
 
 export default {
   name: 'Dashboard',
+  mixins: [userMixin],
   data() {
     return {
-      devops: false,
-      rolePrefix: 'devops_',
       machineStatList: [],
       sysInfo: null
     }
@@ -126,9 +125,7 @@ export default {
   },
   methods: {
     getData() {
-      const role = store.getters.roles[0]
-      if (role.startsWith(this.rolePrefix)) {
-        this.devops = true
+      if (this.devops) {
         this.getDevopsDashboard()
       }
     },