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: 花裤衩 <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

1 comment on commit 088f64e

@mayunhai
Copy link
Contributor

@mayunhai mayunhai commented on 088f64e Mar 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样改存在两个问题:

  1. 当大写锁定 shift 按住输入小写的时候并不能正常提示 大写被锁定
  2. 当提示大写被锁定后并不会只因为 按了 capslock 而关闭 大写被锁定的提示,alt 、ctrl、shift都可以

Please sign in to comment.