import { NotificationType } from '@/typings/notifications' ; import { MessageBox , Notification } from 'element-ui' ; import { ElMessageBoxOptions , MessageBoxInputData , } from 'element-ui/types/message-box' ; import { ElNotificationOptions } from 'element-ui/types/notification' ; param title param message param confirmButtonText export async function alert ( title , message , confirmButtonText = 'OK' , options ? ) { try { await MessageBox . alert ( message , title , { confirmButtonText , ... options , } ) ; return true ; } catch ( err ) { return false ; } } param title param message param confirmButtonText param cancelButtonText param type export async function confirmPrompt ( title , message , confirmButtonText = 'OK' , cancelButtonText = 'Cancel' , type = NotificationType . Info , options ? ) { try { await MessageBox . confirm ( message , title , { confirmButtonText , cancelButtonText , type : NotificationType [ type ] . toLowerCase ( ) as ElNotificationOptions [ 'type' ] , ... options , } ) ; return true ; } catch ( err ) { return false ; } } export async function prompt ( title , message , confirmButtonText = 'OK' , cancelButtonText = 'Cancel' , type = NotificationType . Info , options ? ) { let value = undefined as string | undefined ; let confirm = false ; try { const result = await MessageBox . prompt ( message , title , { confirmButtonText , cancelButtonText , type : NotificationType [ type ] . toLowerCase ( ) as ElNotificationOptions [ 'type' ] , ... options , } ) ; value = ( result as MessageBoxInputData ) . value ; confirm = true ; } catch ( err ) { confirm = false ; } return { confirm , value } ; } param type param title param message export function notify ( type , title , message ) { Notification ( { title , message , type : NotificationType [ type ] . toLowerCase ( ) as ElNotificationOptions [ 'type' ] , position : 'bottom-right' , } ) ; }