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

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

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

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

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

export default PswSetting
