From 088f64eeccf9570120e846f3871dd91df127f3bd Mon Sep 17 00:00:00 2001 From: RussXD Date: Wed, 8 Jan 2020 12:12:10 +0800 Subject: [PATCH] perf: optimize checkCapslock method (#2635) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * optimize checkCapslock method * update Co-authored-by: 花裤衩 --- src/views/login/index.vue | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 5fb3f6e3..25906405 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -138,17 +138,9 @@ export default { // window.removeEventListener('storage', this.afterQRScan) }, methods: { - checkCapslock({ shiftKey, key } = {}) { - if (key && key.length === 1) { - if (shiftKey && (key >= 'a' && key <= 'z') || !shiftKey && (key >= 'A' && key <= 'Z')) { - this.capsTooltip = true - } else { - this.capsTooltip = false - } - } - if (key === 'CapsLock' && this.capsTooltip === true) { - this.capsTooltip = false - } + checkCapslock(e) { + const { key } = e + this.capsTooltip = key && key.length === 1 && (key >= 'A' && key <= 'Z') }, showPwd() { if (this.passwordType === 'password') {