From d6e0c9b8ba5c9ac45dc48301e40a40ca254513d2 Mon Sep 17 00:00:00 2001 From: vinelink <57426410+vinelink@users.noreply.github.com> Date: Thu, 13 Jan 2022 14:35:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20notify=20ts=20=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=AE=8C=E5=96=84=20(#1891)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/zent/src/notify/Notify.tsx | 32 ++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/packages/zent/src/notify/Notify.tsx b/packages/zent/src/notify/Notify.tsx index f460044886..cac1c79921 100644 --- a/packages/zent/src/notify/Notify.tsx +++ b/packages/zent/src/notify/Notify.tsx @@ -1,3 +1,4 @@ +import { ReactNode } from 'react'; import * as ReactDOM from 'react-dom'; import isBrowser from '../utils/isBrowser'; import createElement from '../utils/dom/createElement'; @@ -75,7 +76,12 @@ const createNotifyContainerNode = (): HTMLElement => { * @param {[type]} status notify状态 * @param {Function} callback notify消失时回调 */ -const show = (text, duration, status, callback) => { +const show = ( + text: ReactNode, + duration?: number, + status?: string, + callback?: () => void +) => { if (!isBrowser) return null; const container = createElement('div'); @@ -108,19 +114,35 @@ const show = (text, duration, status, callback) => { return containerId; }; -export function success(text, duration?: number, callback?: () => void) { +export function success( + text: ReactNode, + duration?: number, + callback?: () => void +) { return show(text, duration, 'success', callback); } -export function warn(text, duration?: number, callback?: () => void) { +export function warn( + text: ReactNode, + duration?: number, + callback?: () => void +) { return show(text, duration, 'warn', callback); } -export function error(text, duration?: number, callback?: () => void) { +export function error( + text: ReactNode, + duration?: number, + callback?: () => void +) { return show(text, duration, 'error', callback); } -export function info(text, duration?: number, callback?: () => void) { +export function info( + text: ReactNode, + duration?: number, + callback?: () => void +) { return show(text, duration, 'info', callback); }