Skip to content

Commit 99a344e

Browse files
shangTouPanJiaChen
authored andcommitted
perf: optimize checkCapslock method (PanJiaChen#2635)
* optimize checkCapslock method * update Co-authored-by: 花裤衩 <[email protected]>
1 parent f48c259 commit 99a344e

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

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') {

0 commit comments

Comments
 (0)