import Vue from 'vue' ; import { Confirm } from '@/components' ; class Plugin implements Vue . PluginObject < { } > { private installed : boolean = false ; public install ( vue ) { if ( this . installed ) { return ; } this . installed = true ; Object . defineProperties ( vue . prototype , { $confirm : { value ( message , options = { } ) { return new Promise ( ( resolve , reject ) => { try { const confirm = new Confirm ( { propsData : { title : message , desc : options . desc } , destroyed ( ) { resolve ( confirm . value ) ; } , } ) . $mount ( ) ; } catch ( err ) { reject ( err ) ; } } ) ; } , } , } ) ; } } export const VueConfirm = new Plugin ( ) ;