fix: 修改密码后退出登录

This commit is contained in:
YeMingfei666 2025-03-19 15:31:19 +08:00
parent 47442a52fb
commit b8ea96007a
1 changed files with 27 additions and 43 deletions

View File

@ -18,44 +18,33 @@
modal-append-to-body
append-to-body
v-model="dialogVisible"
@close="reset"
width="400px"
>
<el-form ref="refForm" :model="form" :rules="rules">
<el-form-item label="旧密码" prop="oldPass">
<el-input :type="ip1Type" v-model="form.oldPass" placeholder="请输入旧密码">
<template #suffix>
<i
:class="`el-input__icon ${
ip1Type == 'text' ? 'el-icon-view' : 'el-icon-remove-outline'
}`"
@click.stop="changeInputType('ip1Type')"
></i>
</template>
</el-input>
<el-input
type="password"
show-password
v-model="form.oldPass"
placeholder="请输入旧密码"
></el-input>
</el-form-item>
<el-form-item label="新密码" prop="newPass">
<el-input :type="ip2Type" v-model="form.newPass" placeholder="请输入新密码">
<template #suffix>
<i
:class="`el-input__icon ${
ip2Type == 'text' ? 'el-icon-view' : 'el-icon-remove-outline'
}`"
@click.stop="changeInputType('ip2Type')"
></i>
</template>
</el-input>
<el-input
type="password"
show-password
v-model="form.newPass"
placeholder="请输入新密码"
></el-input>
</el-form-item>
<el-form-item label="确认新密码" prop="rnewPass">
<el-input :type="ip3Type" v-model="form.rnewPass" placeholder="请再次输入新密码">
<template #suffix>
<i
:class="`el-input__icon ${
ip3Type == 'text' ? 'el-icon-view' : 'el-icon-remove-outline'
}`"
@click.stop="changeInputType('ip3Type')"
></i>
</template>
</el-input>
<el-input
type="password"
show-password
v-model="form.rnewPass"
placeholder="请再次输入新密码"
></el-input>
</el-form-item>
</el-form>
<template #footer>
@ -84,25 +73,19 @@ const router = useRouter();
const dialogVisible = ref(false);
const formLoading = ref(false);
const state = reactive({
ip1Type: "password",
ip2Type: "password",
ip3Type: "password",
});
const { ip1Type, ip2Type, ip3Type } = toRefs(state);
const form = reactive({
oldPass: "",
newPass: "",
rnewPass: "",
});
//
function changeInputType(key: "ip1Type" | "ip2Type" | "ip3Type") {
if (state[key] == "text") {
state[key] = "password";
} else {
state[key] = "text";
}
function reset() {
form.oldPass = "";
form.newPass = "";
form.rnewPass = "";
refForm.value.resetFields();
}
const validateNewPass = (rule: any, value: string, callback: (error?: Error) => void) => {
if (!form.newPass) {
callback(new Error(" "));
@ -157,6 +140,7 @@ function submitHandle() {
password: form.newPass,
});
ElNotification.success("修改成功,请重新登陆");
logout();
} catch (error) {
formLoading.value = false;
console.log(error);