import { notification } from 'antd' type Notify = 'success' | 'error' | 'info' | 'warning' export function notify(content: string, title: string = 'Success', type: Notify = 'success') { notification[type]({ message: title, description: content, }) } export function _notify(type: Notify = 'warning') { return (title: string = '提示') => (content: string) => { notify(content, title, type) } } export const warn = _notify()() export const error = _notify('error')() export const success = _notify('success')() export function debounce (callback: Function, timeout: number) { let handler: NodeJS.Timeout return (...params: any[]) => { if (handler) clearTimeout(handler) // @ts-ignore handler = setTimeout(callback.bind(this as any, params), timeout) } }