fix: 修改密码后退出登录

This commit is contained in:
2025-03-19 15:31:19 +08:00
parent 47442a52fb
commit b8ea96007a

View File

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