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
2 people authored and sunshine17 committed Feb 11, 2020
1 parent f48c259 commit 99a344e
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 99a344e

Please sign in to comment.