Skip to content

Commit

Permalink
perf: optimize checkCapslock method (PanJiaChen#2635)
Browse files Browse the repository at this point in the history
* optimize checkCapslock method

* update

Co-authored-by: 花裤衩 <panfree23@gmail.com>
  • Loading branch information
shangTou and PanJiaChen committed Jan 8, 2020
1 parent 55b1bba commit 088f64e
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/views/login/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down

0 comments on commit 088f64e

Please sign in to comment.