import otherInfo from './index.vue'
import i18n from '@/util/lang/lang'

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 }
      },
      i18n,
      data () {
        return {
          visible: false,
          userId
        }
      }
    })

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

export default otherInfo
