import Vue from 'vue'
import Message from './index.vue'

const messageBox = Vue.extend(Message)

Message.install = function (options,{ok,cancel}) {
  if (options === undefined || options === null) {
    options = {
      content: ''
    }
  } else if (typeof options === 'string' || typeof options === 'number') {
    options = {
      content: options
    }
  }

  let instance = new messageBox({
    data: Object.assign(options,{okFunc:ok,cancelFunc:cancel})
  }).$mount()
  document.body.appendChild(instance.$el)

  Vue.nextTick(() => {
    instance.visible = true
  })
}
export default Message
