fix(notification): improve type definition and define closeAll function (#2705)

fix #2696
This commit is contained in:
msidolphin 2021-07-27 09:09:12 +08:00 committed by GitHub
parent 52b474525d
commit 89c01de6f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -2,11 +2,21 @@ import type { VNode } from 'vue'
export type Position = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'
export type NotificationType = 'success' | 'warning' | 'info' | 'error' | ''
export type TypedNotificationOptions = Omit<INotificationOptions, 'type'> | string
export interface INotificationHandle {
close: () => void
}
export type INotification = (options?: INotificationOptions) => INotificationHandle
export interface INotification {
(options?: INotificationOptions) : INotificationHandle
success?: (options: TypedNotificationOptions) => INotificationHandle
warning?: (options: TypedNotificationOptions) => INotificationHandle
error?: (options: TypedNotificationOptions) => INotificationHandle
info?: (options: TypedNotificationOptions) => INotificationHandle
closeAll: () => void
}
export type INotificationOptions = {
customClass?: string
@ -21,7 +31,7 @@ export type INotificationOptions = {
offset?: number // defaults 0
position?: Position // default top-right
showClose?: boolean
type?: 'success' | 'warning' | 'info' | 'error' | ''
type?: NotificationType
title?: string
}

View File

@ -142,4 +142,6 @@ export function closeAll(): void {
}
}
Notification.closeAll = closeAll
export default Notification