Skip to content

Commit

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

* update

Co-authored-by: 花裤衩 <[email protected]>
  • Loading branch information
shangTou and PanJiaChen committed Jan 9, 2020
1 parent 93e0192 commit ea27da4
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 @@ -146,17 +146,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 ea27da4

Please sign in to comment.