index.js 810 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import i18n from '@/util/lang/lang'
  2. let dom = null
  3. async function asyncConstructor (Vue, comp) {
  4. if (!comp) {
  5. let component = await import('./index.vue')
  6. comp = Vue.extend(component.default)
  7. return comp
  8. }
  9. return comp
  10. }
  11. let Info = {}
  12. Info.install = function (Vue, store) {
  13. let instance
  14. Vue.prototype.$showUserInfo = async () => {
  15. let Constructor = await asyncConstructor(Vue, dom)
  16. if (instance) {
  17. instance.visible = true
  18. } else {
  19. instance = new Constructor({
  20. el: document.createElement('div'),
  21. computed: {
  22. $store () { return store }
  23. },
  24. i18n,
  25. data () {
  26. return {
  27. visible: true
  28. }
  29. }
  30. })
  31. document.body.appendChild(instance.$el)
  32. }
  33. }
  34. }
  35. export default Info