From e0b2db7dee72a3191f5477ed0aca16ac6dcc40bf Mon Sep 17 00:00:00 2001 From: hymbz Date: Tue, 23 Jan 2024 00:14:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20:bug:=20=E4=BF=AE=E5=A4=8D=E4=BC=9A?= =?UTF-8?q?=E5=9C=A8=E7=BD=91=E9=A1=B5=E5=8A=A0=E8=BD=BD=E8=BF=87=E6=85=A2?= =?UTF-8?q?=E6=97=B6=E5=85=B3=E9=97=AD=E7=AE=80=E6=98=93=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://sleazyfork.org/zh-CN/scripts/374903/discussions/224616 --- src/components/Toast/ToastItem.tsx | 7 ++++++- src/components/Toast/index.ts | 1 + src/site/other.ts | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/Toast/ToastItem.tsx b/src/components/Toast/ToastItem.tsx index 6b32b68f..1ed5c92c 100644 --- a/src/components/Toast/ToastItem.tsx +++ b/src/components/Toast/ToastItem.tsx @@ -70,13 +70,18 @@ export const ToastItem: Component = (props) => { }); }); + const handleClick: EventHandler['on:click'] = (e) => { + props.onClick?.(); + dismiss(e); + }; + return (
diff --git a/src/components/Toast/index.ts b/src/components/Toast/index.ts index a5715ca0..59d89800 100644 --- a/src/components/Toast/index.ts +++ b/src/components/Toast/index.ts @@ -17,6 +17,7 @@ export interface Toast { /** 弹窗完报错 */ throw?: true | Error; onDismiss?: (t: Toast) => void; + onClick?: () => void; exit?: true; update?: true; } diff --git a/src/site/other.ts b/src/site/other.ts index c4be940a..aa071727 100644 --- a/src/site/other.ts +++ b/src/site/other.ts @@ -178,7 +178,7 @@ import { toast.warn(t('site.simple.no_img'), { id: 'no_img', duration: Infinity, - onDismiss: async () => { + onClick: async () => { await setOptions({ remember_current_site: false }); window.location.reload(); },