diff --git a/ant-design-vue-jeecg/src/views/user/LoginAccount.vue b/ant-design-vue-jeecg/src/views/user/LoginAccount.vue index 653ddc1..018b1c7 100644 --- a/ant-design-vue-jeecg/src/views/user/LoginAccount.vue +++ b/ant-design-vue-jeecg/src/views/user/LoginAccount.vue @@ -7,8 +7,7 @@ </a-input> </a-form-model-item> <a-form-model-item required prop="password"> - <a-input v-model="model.password" size="large" type="text" autocomplete="off" @input="maskPassword" - placeholder="请输入密码 / 123456" > + <a-input v-model="model.password" size="large" type="text" autocomplete="off" @input="maskPassword" placeholder="请输入密码" > <a-icon slot="prefix" type="lock" :style="{ color: 'rgba(0,0,0,.25)' }"/> </a-input> </a-form-model-item> @@ -105,14 +104,29 @@ export default { }, maskPassword() { - if (this.model.password.length<this.maskedPassword.length){ - let len=this.maskedPassword.length-this.model.password.length - this.maskedPassword=this.maskedPassword.substring(0,this.maskedPassword.length - len) - }else{ - this.maskedPassword = this.maskedPassword + this.model.password.substring(this.model.password.length - 1, this.model.password.length) + //获取输入框的值 + let value = this.model.password + if (value != '') { + //如果不为空,逐个字符判断是否为圆点 + for (let i = 0; i < value.length; i++) { + if (value.charAt(i) != '\u25CF') { + //如果不是圆点,表示该字符为用户输入的值,放到真实值的对应位置 + let char = value.charAt(i) + this.maskedPassword = this.maskedPassword.slice(0, i) + char + this.maskedPassword.slice(i) + //将该字符替换为圆点 + value = value.slice(0, i) + '\u25CF' + value.slice(i + 1) + } + } + //防止真实值和圆点的数量不对应。 + this.maskedPassword = this.maskedPassword.slice(0, value.length) + //将转换过的字符串显示给用户 + this.model.password = value + } else { + //保持一致性 + this.maskedPassword = '' } - this.model.password = '*'.repeat(this.model.password.length); }, + // 判断登录类型 handleUsernameOrEmail(rule, value, callback) { const regex = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;