diff --git a/components/ui/Toast.tsx b/components/ui/Toast.tsx index 689017d..e44837e 100644 --- a/components/ui/Toast.tsx +++ b/components/ui/Toast.tsx @@ -65,8 +65,10 @@ const Toast = (function () { // }) let toastTimer: number | null = null - const show = (params?: ShowParams): void => { - const { renderContent, title, duration = 4000, hideBackdrop = true } = params || {} + const show = (params?: ShowParams | string): void => { + // 兼容字符串参数 + const options: ShowParams = typeof params === 'string' ? { title: params } : (params || {}) + const { renderContent, title, duration = 4000, hideBackdrop = true } = options hide() const renderBody = (): ReactNode => {