refactor: ♻️ 自行实现是否展示密码功能
This commit is contained in:
@@ -23,14 +23,19 @@
|
|||||||
<el-input
|
<el-input
|
||||||
v-model.trim="loginFormData.password"
|
v-model.trim="loginFormData.password"
|
||||||
:placeholder="t('login.password')"
|
:placeholder="t('login.password')"
|
||||||
type="password"
|
:type="showPasswordRef ? 'text' : 'password'"
|
||||||
show-password
|
|
||||||
@keyup="checkCapsLock"
|
@keyup="checkCapsLock"
|
||||||
@keyup.enter="handleLoginSubmit"
|
@keyup.enter="handleLoginSubmit"
|
||||||
>
|
>
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<el-icon><Lock /></el-icon>
|
<el-icon><Lock /></el-icon>
|
||||||
</template>
|
</template>
|
||||||
|
<template #suffix>
|
||||||
|
<el-icon v-if="!showPasswordRef" cursor-pointer @click="showPassword">
|
||||||
|
<View />
|
||||||
|
</el-icon>
|
||||||
|
<el-icon v-else cursor-pointer @click="showPassword"><Hide /></el-icon>
|
||||||
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
@@ -132,6 +137,8 @@ const isCapsLock = ref(false);
|
|||||||
const captchaBase64 = ref();
|
const captchaBase64 = ref();
|
||||||
// 记住我
|
// 记住我
|
||||||
const rememberMe = AuthStorage.getRememberMe();
|
const rememberMe = AuthStorage.getRememberMe();
|
||||||
|
// 是否显示密码
|
||||||
|
const showPasswordRef = ref(false);
|
||||||
|
|
||||||
const loginFormData = ref<LoginFormData>({
|
const loginFormData = ref<LoginFormData>({
|
||||||
username: "admin",
|
username: "admin",
|
||||||
@@ -217,6 +224,10 @@ function checkCapsLock(event: KeyboardEvent) {
|
|||||||
isCapsLock.value = event.getModifierState("CapsLock");
|
isCapsLock.value = event.getModifierState("CapsLock");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 切换密码显示
|
||||||
|
function showPassword() {
|
||||||
|
showPasswordRef.value = !showPasswordRef.value;
|
||||||
|
}
|
||||||
|
|
||||||
const emit = defineEmits(["update:modelValue"]);
|
const emit = defineEmits(["update:modelValue"]);
|
||||||
function toOtherForm(type: "register" | "resetPwd") {
|
function toOtherForm(type: "register" | "resetPwd") {
|
||||||
|
|||||||
Reference in New Issue
Block a user