Skip to content

Commit 088f64e

Browse files
shangTouPanJiaChen
andcommittedJan 8, 2020
perf: optimize checkCapslock method (#2635)
* optimize checkCapslock method * update Co-authored-by: 花裤衩 <[email protected]>
1 parent 55b1bba commit 088f64e

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed
 

Diff for: ‎src/views/login/index.vue

+3-11
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,9 @@ export default {
138138
// window.removeEventListener('storage', this.afterQRScan)
139139
},
140140
methods: {
141-
checkCapslock({ shiftKey, key } = {}) {
142-
if (key && key.length === 1) {
143-
if (shiftKey && (key >= 'a' && key <= 'z') || !shiftKey && (key >= 'A' && key <= 'Z')) {
144-
this.capsTooltip = true
145-
} else {
146-
this.capsTooltip = false
147-
}
148-
}
149-
if (key === 'CapsLock' && this.capsTooltip === true) {
150-
this.capsTooltip = false
151-
}
141+
checkCapslock(e) {
142+
const { key } = e
143+
this.capsTooltip = key && key.length === 1 && (key >= 'A' && key <= 'Z')
152144
},
153145
showPwd() {
154146
if (this.passwordType === 'password') {

1 commit comments

Comments
 (1)

mayunhai commented on Mar 5, 2020

@mayunhai
Contributor

这样改存在两个问题:

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