feat: 移除不必要的 toastController 导入,优化密码修改成功提示逻辑

This commit is contained in:
2026-01-26 15:19:27 +07:00
parent 05a40f2062
commit d472a0d905
2 changed files with 9 additions and 20 deletions

1
auto-imports.d.ts vendored
View File

@@ -451,7 +451,6 @@ declare module 'vue' {
readonly shallowReactive: UnwrapRef<typeof import('vue')['shallowReactive']>
readonly shallowReadonly: UnwrapRef<typeof import('vue')['shallowReadonly']>
readonly shallowRef: UnwrapRef<typeof import('vue')['shallowRef']>
readonly showSuccessToast: UnwrapRef<typeof import('vant/es')['showSuccessToast']>
readonly showToast: UnwrapRef<typeof import('vant/es')['showToast']>
readonly storeToRefs: UnwrapRef<typeof import('pinia')['storeToRefs']>
readonly syncRef: UnwrapRef<typeof import('@vueuse/core')['syncRef']>

View File

@@ -1,5 +1,4 @@
<script lang='ts' setup>
import { toastController } from "@ionic/vue";
import { eyeOffOutline, eyeOutline, lockClosedOutline } from "ionicons/icons";
import zod from "zod";
import { safeClient } from "@/api";
@@ -17,6 +16,7 @@ const showCurrentPassword = ref(false);
const showNewPassword = ref(false);
const showConfirmPassword = ref(false);
const isSubmitting = ref(false);
const userStore = useUserStore();
// 表单验证 Schema
const ChangePasswordSchema = zod.object({
@@ -41,16 +41,6 @@ const ChangePasswordSchema = zod.object({
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() {
const result = ChangePasswordSchema.safeParse(formData.value);
if (!result.success) {
@@ -66,12 +56,12 @@ async function handleSubmit() {
currentPassword: formData.value.currentPassword, // required
revokeOtherSessions: true,
}));
await showToast("登录密码修改成功,请使用新密码登录", "success");
await showToast("登录密码修改成功,请使用新密码登录");
userStore.signOut(); // 修改密码后登出
router.back();
}
catch (error) {
await showToast("密码修改失败,请检查当前密码是否正确", "danger");
await showToast("密码修改失败,请检查当前密码是否正确");
}
finally {
isSubmitting.value = false;
@@ -246,16 +236,16 @@ async function handleSubmit() {
}
.custom-input {
--placeholder-color: #999;
--placeholder-opacity: 1;
font-size: 15px;
--padding-start: 0;
--padding-end: 0;
font-size: 16px;
color: #2c3e50;
}
.password-toggle {
font-size: 20px;
font-size: 16px;
color: #999;
cursor: pointer;
padding: 8px;
}
.password-toggle:hover {