import Vue from 'vue'
import MyModal from './my-modal'

let currentModal
const Instance = Vue.extend(MyModal)
const initInstance = () => {
  // 实例化vue实例
  currentModal = new Instance()
  document.body.appendChild(currentModal.$mount().$el)
}

export default function install () {
  Vue.prototype.$MyModal = {
    show (option) {
      if (!currentModal) {
        initInstance()
      }
      currentModal.show(option)
      return currentModal
    }
  }
}
