perf[Login]: password input add caps tooltip (#1845)

This commit is contained in:
MaYuanhai 2019-04-08 14:13:07 +08:00 committed by 花裤衩
parent e3b6602bbf
commit 0358667a73
1 changed files with 35 additions and 18 deletions

View File

@ -23,24 +23,28 @@
/> />
</el-form-item> </el-form-item>
<el-form-item prop="password"> <el-tooltip v-model="capsTooltip" content="Caps lock is On" placement="right" manual>
<span class="svg-container"> <el-form-item prop="password">
<svg-icon icon-class="password" /> <span class="svg-container">
</span> <svg-icon icon-class="password" />
<el-input </span>
:key="passwordType" <el-input
ref="password" :key="passwordType"
v-model="loginForm.password" ref="password"
:type="passwordType" v-model="loginForm.password"
:placeholder="$t('login.password')" :type="passwordType"
name="password" :placeholder="$t('login.password')"
auto-complete="on" name="password"
@keyup.enter.native="handleLogin" auto-complete="on"
/> @keyup.native="checkCapslock"
<span class="show-pwd" @click="showPwd"> @blur="capsTooltip = false"
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" /> @keyup.enter.native="handleLogin"
</span> />
</el-form-item> <span class="show-pwd" @click="showPwd">
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
</span>
</el-form-item>
</el-tooltip>
<el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" @click.native.prevent="handleLogin"> <el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" @click.native.prevent="handleLogin">
{{ $t('login.logIn') }} {{ $t('login.logIn') }}
@ -107,6 +111,7 @@ export default {
password: [{ required: true, trigger: 'blur', validator: validatePassword }] password: [{ required: true, trigger: 'blur', validator: validatePassword }]
}, },
passwordType: 'password', passwordType: 'password',
capsTooltip: false,
loading: false, loading: false,
showDialog: false, showDialog: false,
redirect: undefined redirect: undefined
@ -134,6 +139,18 @@ export default {
// window.removeEventListener('storage', this.afterQRScan) // window.removeEventListener('storage', this.afterQRScan)
}, },
methods: { 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
}
},
showPwd() { showPwd() {
if (this.passwordType === 'password') { if (this.passwordType === 'password') {
this.passwordType = '' this.passwordType = ''