Procházet zdrojové kódy

修改登录账号密码空格提示

DESKTOP-227F4HN\Zt před 2 roky
rodič
revize
eed44a347e

+ 6 - 7
chuanyi-admin/src/store/modules/permission.js

@@ -80,13 +80,12 @@ const actions = {
    */
   GenerateRoutes({ commit }, roles) {
     let roleIdList = []
-    roles.forEach((e) => {
-      if (roles.length >= 1 && e.roleCode === 'ManagerRole') {
-        roleIdList = [1]
-      } else {
-        roleIdList = [2]
-      }
-    })
+    const rCode = roles.find((item) => item.roleCode === 'ManagerRole')
+    if (rCode) {
+      roleIdList = [1]
+    } else if (rCode === undefined) {
+      roleIdList = [2]
+    }
     return new Promise((resolve) => {
       // 向后端请求路由数据
       getRouters(roleIdList).then((res) => {

+ 1 - 1
chuanyi-admin/src/utils/errorCode.js

@@ -2,7 +2,7 @@ export default {
   '401': '认证失败,无法访问系统资源',
   '403': '当前操作没有权限',
   '404': '访问资源不存在',
-
+  '500': '用户名或密码输入错误',
   '900': '初始化未完成,请稍候再试',
   '901': '数据正在处理,请勿重复提交',
   '902': '下载文件出现错误,请联系管理员',

+ 27 - 19
chuanyi-admin/src/views/login/index.vue

@@ -25,7 +25,12 @@
           auto-complete="off"
         />
       </el-form-item>
-      <el-tooltip v-model="capsTooltip" content="已开启大写字母" placement="right" manual>
+      <el-tooltip
+        v-model="capsTooltip"
+        content="已开启大写字母"
+        placement="bottom-start"
+        manual
+      >
         <el-form-item prop="password">
           <span class="svg-container">
             <svg-icon icon-class="password" />
@@ -43,13 +48,23 @@
             @blur="capsTooltip = false"
             @keyup.enter.native="handleLogin"
           />
-          <span class="show-pwd" @click="showPwd">
+          <span
+            class="show-pwd"
+            @click="showPwd"
+          >
             <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
           </span>
         </el-form-item>
       </el-tooltip>
-      <el-form-item v-if="captchaEnabled" prop="code" class="code-div">
-        <div class="el-form-item" style="width: 63%;float: left;">
+      <el-form-item
+        v-if="captchaEnabled"
+        prop="code"
+        class="code-div"
+      >
+        <div
+          class="el-form-item"
+          style="width: 63%;float: left;"
+        >
           <span class="svg-container">
             <svg-icon icon-class="validCode" />
           </span>
@@ -64,7 +79,11 @@
           />
         </div>
         <div class="login-code">
-          <img :src="codeUrl" class="login-code-img" @click="getCode">
+          <img
+            :src="codeUrl"
+            class="login-code-img"
+            @click="getCode"
+          >
         </div>
       </el-form-item>
       <el-button
@@ -97,8 +116,8 @@ export default {
         uid: ''
       },
       loginRules: {
-        userName: [{ required: true, trigger: 'blur', message: '请输入您的帐号' }],
-        password: [{ required: true, trigger: 'blur', message: '请输入您的密码' }],
+        userName: [{ required: true, trigger: ['blur', 'change'], message: '请输入您的用户名', pattern: '[^ \x22]+' }],
+        password: [{ required: true, trigger: ['blur', 'change'], message: '请输入您的密码', pattern: '[^ \x22]+' }],
         code: [{ required: true, trigger: 'change', message: '请输入验证码' }]
       },
       passwordType: 'password',
@@ -165,6 +184,7 @@ export default {
       }
       this.$refs.loginForm.validate(valid => {
         if (valid) {
+          console.log(this.loginForm)
           this.loading = true
           this.$store.dispatch('user/Login', this.loginForm).then(() => {
             this.$router.push({ path: this.redirect || '/', query: this.otherQuery })
@@ -175,17 +195,6 @@ export default {
               this.getCode()
             }
           })
-          // const pwd = encrypt(this.loginForm.password, this.publicKey)
-          // login(this.loginForm.username.trim(), pwd, this.loginForm.code, this.loginForm.uid).then(res => {
-          //   console.log(res)
-          //   setUserInfo(res.data.user, res.data.token)
-          //   this.$router.push({ path: this.redirect || '/', query: this.otherQuery })
-          // }).catch((e) => {
-          //   this.loading = false
-          //   if (this.captchaEnabled) {
-          //     this.getCode()
-          //   }
-          // })
         }
       })
     },
@@ -301,6 +310,5 @@ $dark_gray: #889aa4;
   .login-code-img {
     height: 38px;
   }
-
 }
 </style>