Skip to content

Commit 0358667

Browse files
mayunhaiPanJiaChen
authored andcommitted
perf[Login]: password input add caps tooltip (PanJiaChen#1845)
1 parent e3b6602 commit 0358667

File tree

1 file changed

+35
-18
lines changed

1 file changed

+35
-18
lines changed

src/views/login/index.vue

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,28 @@
2323
/>
2424
</el-form-item>
2525

26-
<el-form-item prop="password">
27-
<span class="svg-container">
28-
<svg-icon icon-class="password" />
29-
</span>
30-
<el-input
31-
:key="passwordType"
32-
ref="password"
33-
v-model="loginForm.password"
34-
:type="passwordType"
35-
:placeholder="$t('login.password')"
36-
name="password"
37-
auto-complete="on"
38-
@keyup.enter.native="handleLogin"
39-
/>
40-
<span class="show-pwd" @click="showPwd">
41-
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
42-
</span>
43-
</el-form-item>
26+
<el-tooltip v-model="capsTooltip" content="Caps lock is On" placement="right" manual>
27+
<el-form-item prop="password">
28+
<span class="svg-container">
29+
<svg-icon icon-class="password" />
30+
</span>
31+
<el-input
32+
:key="passwordType"
33+
ref="password"
34+
v-model="loginForm.password"
35+
:type="passwordType"
36+
:placeholder="$t('login.password')"
37+
name="password"
38+
auto-complete="on"
39+
@keyup.native="checkCapslock"
40+
@blur="capsTooltip = false"
41+
@keyup.enter.native="handleLogin"
42+
/>
43+
<span class="show-pwd" @click="showPwd">
44+
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
45+
</span>
46+
</el-form-item>
47+
</el-tooltip>
4448

4549
<el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" @click.native.prevent="handleLogin">
4650
{{ $t('login.logIn') }}
@@ -107,6 +111,7 @@ export default {
107111
password: [{ required: true, trigger: 'blur', validator: validatePassword }]
108112
},
109113
passwordType: 'password',
114+
capsTooltip: false,
110115
loading: false,
111116
showDialog: false,
112117
redirect: undefined
@@ -134,6 +139,18 @@ export default {
134139
// window.removeEventListener('storage', this.afterQRScan)
135140
},
136141
methods: {
142+
checkCapslock({ shiftKey, key } = {}) {
143+
if (key && key.length === 1) {
144+
if (shiftKey && (key >= 'a' && key <= 'z') || !shiftKey && (key >= 'A' && key <= 'Z')) {
145+
this.capsTooltip = true
146+
} else {
147+
this.capsTooltip = false
148+
}
149+
}
150+
if (key === 'CapsLock' && this.capsTooltip === true) {
151+
this.capsTooltip = false
152+
}
153+
},
137154
showPwd() {
138155
if (this.passwordType === 'password') {
139156
this.passwordType = ''

0 commit comments

Comments
 (0)