feat: 移除不必要的 toastController 导入,优化密码修改成功提示逻辑
This commit is contained in:
1
auto-imports.d.ts
vendored
1
auto-imports.d.ts
vendored
@@ -451,7 +451,6 @@ declare module 'vue' {
|
|||||||
readonly shallowReactive: UnwrapRef<typeof import('vue')['shallowReactive']>
|
readonly shallowReactive: UnwrapRef<typeof import('vue')['shallowReactive']>
|
||||||
readonly shallowReadonly: UnwrapRef<typeof import('vue')['shallowReadonly']>
|
readonly shallowReadonly: UnwrapRef<typeof import('vue')['shallowReadonly']>
|
||||||
readonly shallowRef: UnwrapRef<typeof import('vue')['shallowRef']>
|
readonly shallowRef: UnwrapRef<typeof import('vue')['shallowRef']>
|
||||||
readonly showSuccessToast: UnwrapRef<typeof import('vant/es')['showSuccessToast']>
|
|
||||||
readonly showToast: UnwrapRef<typeof import('vant/es')['showToast']>
|
readonly showToast: UnwrapRef<typeof import('vant/es')['showToast']>
|
||||||
readonly storeToRefs: UnwrapRef<typeof import('pinia')['storeToRefs']>
|
readonly storeToRefs: UnwrapRef<typeof import('pinia')['storeToRefs']>
|
||||||
readonly syncRef: UnwrapRef<typeof import('@vueuse/core')['syncRef']>
|
readonly syncRef: UnwrapRef<typeof import('@vueuse/core')['syncRef']>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<script lang='ts' setup>
|
<script lang='ts' setup>
|
||||||
import { toastController } from "@ionic/vue";
|
|
||||||
import { eyeOffOutline, eyeOutline, lockClosedOutline } from "ionicons/icons";
|
import { eyeOffOutline, eyeOutline, lockClosedOutline } from "ionicons/icons";
|
||||||
import zod from "zod";
|
import zod from "zod";
|
||||||
import { safeClient } from "@/api";
|
import { safeClient } from "@/api";
|
||||||
@@ -17,6 +16,7 @@ const showCurrentPassword = ref(false);
|
|||||||
const showNewPassword = ref(false);
|
const showNewPassword = ref(false);
|
||||||
const showConfirmPassword = ref(false);
|
const showConfirmPassword = ref(false);
|
||||||
const isSubmitting = ref(false);
|
const isSubmitting = ref(false);
|
||||||
|
const userStore = useUserStore();
|
||||||
|
|
||||||
// 表单验证 Schema
|
// 表单验证 Schema
|
||||||
const ChangePasswordSchema = zod.object({
|
const ChangePasswordSchema = zod.object({
|
||||||
@@ -41,16 +41,6 @@ const ChangePasswordSchema = zod.object({
|
|||||||
path: ["newPassword"],
|
path: ["newPassword"],
|
||||||
});
|
});
|
||||||
|
|
||||||
async function showToast(message: string, color: "success" | "danger" | "warning" = "danger") {
|
|
||||||
const toast = await toastController.create({
|
|
||||||
message,
|
|
||||||
duration: 2000,
|
|
||||||
position: "top",
|
|
||||||
color,
|
|
||||||
});
|
|
||||||
await toast.present();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
const result = ChangePasswordSchema.safeParse(formData.value);
|
const result = ChangePasswordSchema.safeParse(formData.value);
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
@@ -66,12 +56,12 @@ async function handleSubmit() {
|
|||||||
currentPassword: formData.value.currentPassword, // required
|
currentPassword: formData.value.currentPassword, // required
|
||||||
revokeOtherSessions: true,
|
revokeOtherSessions: true,
|
||||||
}));
|
}));
|
||||||
|
await showToast("登录密码修改成功,请使用新密码登录");
|
||||||
await showToast("登录密码修改成功,请使用新密码登录", "success");
|
userStore.signOut(); // 修改密码后登出
|
||||||
router.back();
|
router.back();
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
await showToast("密码修改失败,请检查当前密码是否正确", "danger");
|
await showToast("密码修改失败,请检查当前密码是否正确");
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
isSubmitting.value = false;
|
isSubmitting.value = false;
|
||||||
@@ -246,16 +236,16 @@ async function handleSubmit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.custom-input {
|
.custom-input {
|
||||||
--placeholder-color: #999;
|
--padding-start: 0;
|
||||||
--placeholder-opacity: 1;
|
--padding-end: 0;
|
||||||
font-size: 15px;
|
font-size: 16px;
|
||||||
|
color: #2c3e50;
|
||||||
}
|
}
|
||||||
|
|
||||||
.password-toggle {
|
.password-toggle {
|
||||||
font-size: 20px;
|
font-size: 16px;
|
||||||
color: #999;
|
color: #999;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
padding: 8px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.password-toggle:hover {
|
.password-toggle:hover {
|
||||||
|
|||||||
Reference in New Issue
Block a user