import otherInfo from './index.vue'

otherInfo.install = function (Vue, store, router) {
  const Constructor = Vue.extend(otherInfo)
  let instance

  Vue.prototype.$showOtherInfo = (userId = 0) => {
    if (instance) {
      document.body.removeChild(instance.$el)
      instance = null
    }

    instance = new Constructor({
      el: document.createElement('div'),
      router,
      computed: {
        $store () { return store }
      },
      data () {
        return {
          visible: true,
          userId
        }
      }
    })

    document.body.appendChild(instance.$el)
  }
}

export default otherInfo
