import type { NotifyOptions as VantNotifyOptions, NotifyType as VantNotifyType } from 'vant'; import { closeNotify, showNotify } from 'vant'; import 'vant/es/notify/style'; type NotifyType = 'info' | 'success' | 'error' | 'warning' type NotifyOptions = Omit; export class Notify { static Type: Record = { info: 'primary', success: 'success', error: 'danger', warning: 'warning', }; static show(type: NotifyType, message: string, options?: NotifyOptions) { const notifyRef = showNotify({ type: this.Type[type] as VantNotifyType, message, ...options }); return { notifyRef, close: Notify.close }; } static close() { closeNotify(); } static info(message: string, options?: NotifyOptions) { return this.show('info', message, options); } static success(message: string, options?: NotifyOptions) { return this.show('success', message, options); } static warning(message: string, options?: NotifyOptions) { return this.show('warning', message, options); } static error(message: string, options?: NotifyOptions) { return this.show('error', message, options); } }