diff --git a/src/views/security/index.vue b/src/views/security/index.vue index ba0bbfb..2baa77e 100644 --- a/src/views/security/index.vue +++ b/src/views/security/index.vue @@ -8,16 +8,6 @@ const { data: status, execute } = await safeClient(() => client.api.user.securit const hasPaymentPassword = computed(() => status.value?.enabled ?? false); const toggleInst = ref(null); -async function showToast(message: string, color: "success" | "danger" | "warning" = "success") { - const toast = await toastController.create({ - message, - duration: 2000, - position: "top", - color, - }); - await toast.present(); -} - function handleChangePassword() { router.push("/security/change_password"); } @@ -47,17 +37,20 @@ async function handleTogglePaymentPassword() { { text: "取消", role: "cancel", + handler: () => { + (toggleInst.value as any)!.$el.checked = !(toggleInst.value as any)!.$el.checked; + }, }, { text: "确认", role: "confirm", handler: async (data) => { if (!data.oldPassword) { - await showToast("请输入交易密码", "danger"); + showToast("请输入交易密码"); return false; } if (data.oldPassword.length < 6) { - await showToast("交易密码至少6位", "danger"); + showToast("交易密码至少6位"); return false; } @@ -66,7 +59,7 @@ async function handleTogglePaymentPassword() { })); if (!error.value) { - await showToast("交易密码功能已关闭", "warning"); + showToast("交易密码功能已关闭"); await execute(); return true; } @@ -106,24 +99,27 @@ async function handleTogglePaymentPassword() { { text: "取消", role: "cancel", + handler: () => { + (toggleInst.value as any)!.$el.checked = !(toggleInst.value as any)!.$el.checked; + }, }, { text: "确认", handler: async (data) => { if (!data.password || !data.confirmPassword) { - await showToast("请输入交易密码", "danger"); + showToast("请输入交易密码"); return false; } if (data.password.length < 6) { - await showToast("交易密码至少6位", "danger"); + showToast("交易密码至少6位"); return false; } if (data.password !== data.confirmPassword) { - await showToast("两次输入的密码不一致", "danger"); + showToast("两次输入的密码不一致"); return false; } if (!/^\d+$/.test(data.password)) { - await showToast("交易密码只能包含数字", "danger"); + showToast("交易密码只能包含数字"); return false; } @@ -132,7 +128,7 @@ async function handleTogglePaymentPassword() { })); if (!error.value) { - await showToast("交易密码设置成功"); + showToast("交易密码设置成功"); await execute(); return true; }