Commit 4f2659c0d96827f8b5f17e8263c26a6f7479a9a3
1 parent
40aba46a
登录密码复制问题修复
Signed-off-by: TanYibin <5491541@qq.com>
Showing
1 changed file
with
22 additions
and
8 deletions
ant-design-vue-jeecg/src/views/user/LoginAccount.vue
@@ -7,8 +7,7 @@ | @@ -7,8 +7,7 @@ | ||
7 | </a-input> | 7 | </a-input> |
8 | </a-form-model-item> | 8 | </a-form-model-item> |
9 | <a-form-model-item required prop="password"> | 9 | <a-form-model-item required prop="password"> |
10 | - <a-input v-model="model.password" size="large" type="text" autocomplete="off" @input="maskPassword" | ||
11 | - placeholder="请输入密码 / 123456" > | 10 | + <a-input v-model="model.password" size="large" type="text" autocomplete="off" @input="maskPassword" placeholder="请输入密码" > |
12 | <a-icon slot="prefix" type="lock" :style="{ color: 'rgba(0,0,0,.25)' }"/> | 11 | <a-icon slot="prefix" type="lock" :style="{ color: 'rgba(0,0,0,.25)' }"/> |
13 | </a-input> | 12 | </a-input> |
14 | </a-form-model-item> | 13 | </a-form-model-item> |
@@ -105,14 +104,29 @@ export default { | @@ -105,14 +104,29 @@ export default { | ||
105 | }, | 104 | }, |
106 | 105 | ||
107 | maskPassword() { | 106 | maskPassword() { |
108 | - if (this.model.password.length<this.maskedPassword.length){ | ||
109 | - let len=this.maskedPassword.length-this.model.password.length | ||
110 | - this.maskedPassword=this.maskedPassword.substring(0,this.maskedPassword.length - len) | ||
111 | - }else{ | ||
112 | - this.maskedPassword = this.maskedPassword + this.model.password.substring(this.model.password.length - 1, this.model.password.length) | 107 | + //获取输入框的值 |
108 | + let value = this.model.password | ||
109 | + if (value != '') { | ||
110 | + //如果不为空,逐个字符判断是否为圆点 | ||
111 | + for (let i = 0; i < value.length; i++) { | ||
112 | + if (value.charAt(i) != '\u25CF') { | ||
113 | + //如果不是圆点,表示该字符为用户输入的值,放到真实值的对应位置 | ||
114 | + let char = value.charAt(i) | ||
115 | + this.maskedPassword = this.maskedPassword.slice(0, i) + char + this.maskedPassword.slice(i) | ||
116 | + //将该字符替换为圆点 | ||
117 | + value = value.slice(0, i) + '\u25CF' + value.slice(i + 1) | ||
118 | + } | ||
119 | + } | ||
120 | + //防止真实值和圆点的数量不对应。 | ||
121 | + this.maskedPassword = this.maskedPassword.slice(0, value.length) | ||
122 | + //将转换过的字符串显示给用户 | ||
123 | + this.model.password = value | ||
124 | + } else { | ||
125 | + //保持一致性 | ||
126 | + this.maskedPassword = '' | ||
113 | } | 127 | } |
114 | - this.model.password = '*'.repeat(this.model.password.length); | ||
115 | }, | 128 | }, |
129 | + | ||
116 | // 判断登录类型 | 130 | // 判断登录类型 |
117 | handleUsernameOrEmail(rule, value, callback) { | 131 | handleUsernameOrEmail(rule, value, callback) { |
118 | const regex = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/; | 132 | const regex = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/; |