Skip to content

Commit b11e9b7

Browse files
mayunhaiillidanet
authored andcommitted
perf[Login]: password input add caps tooltip (PanJiaChen#1845)
1 parent c4872df commit b11e9b7

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:50%;margin-bottom:30px;" @click.native.prevent="handleLogin">
4650
{{ $t('login.logIn') }}
@@ -111,6 +115,7 @@ export default {
111115
password: [{ required: true, trigger: 'blur', validator: validatePassword }]
112116
},
113117
passwordType: 'password',
118+
capsTooltip: false,
114119
loading: false,
115120
showDialog: false,
116121
redirect: undefined
@@ -138,6 +143,18 @@ export default {
138143
// window.removeEventListener('storage', this.afterQRScan)
139144
},
140145
methods: {
146+
checkCapslock({ shiftKey, key } = {}) {
147+
if (key && key.length === 1) {
148+
if (shiftKey && (key >= 'a' && key <= 'z') || !shiftKey && (key >= 'A' && key <= 'Z')) {
149+
this.capsTooltip = true
150+
} else {
151+
this.capsTooltip = false
152+
}
153+
}
154+
if (key === 'CapsLock' && this.capsTooltip === true) {
155+
this.capsTooltip = false
156+
}
157+
},
141158
showPwd() {
142159
if (this.passwordType === 'password') {
143160
this.passwordType = ''

0 commit comments

Comments
 (0)