feat: 设备管理优化-0510-密码框修复

演示数据2.0
chenhc 11 months ago
parent 008df9574b
commit d228e1d9e7

@ -197,41 +197,27 @@ export default {
setPassword(val) {
if (this.isShowPassword) {
this.password = val;
this.pwdCover = val; // pwdCover
} else {
// let reg = /[0-9a-zA-Z]/g; //
let nDot = /[^●]/g; //
let index = -1; //
let lastChar = void 0; //
let realArr = this.password.split(""); //
let coverArr = val.split(""); //
let coverLen = val.length; //
let realLen = this.password.length; //
//
coverArr.forEach((el, idx) => {
if (nDot.test(el)) {
index = idx;
lastChar = el;
let realLen = realArr.length; //
//
if (coverLen < realLen) {
//
realArr.splice(coverLen);
} else if (coverLen > realLen) {
//
for (let i = realLen; i < coverLen; i++) {
//
//
realArr.push(coverArr[i]);
}
});
//
// if (lastChar && !reg.test(lastChar)) {
// coverArr.splice(index, 1);
// this.pwdCover = coverArr.join("");
// return;
// }
if (realLen < coverLen) {
//
realArr.splice(index, 0, lastChar);
} else if (coverLen <= realLen && index !== -1) {
//
realArr.splice(index, realLen - (coverLen - 1), lastChar);
} else {
// val password val
let pos = document.getElementById("pwd").selectionEnd; //
realArr.splice(pos, realLen - coverLen);
}
// pwdCover
this.pwdCover = val.replace(/\S/g, "●");
//
this.password = realArr.join("");
}
},

Loading…
Cancel
Save