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

otherInfo.install = function (Vue, store) {
  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'),
      computed: {
        $store () { return store }
      },
      data () {
        return {
          visible: true,
          userId
        }
      },
      i18n
    })

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

export default otherInfo
