index.js 877 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 otherInfo = {}
  12. otherInfo.install = function (Vue, store, router) {
  13. let instance
  14. Vue.prototype.$showOtherInfo = async (userId = 0) => {
  15. let Constructor = await asyncConstructor(Vue, dom)
  16. if (instance) {
  17. document.body.removeChild(instance.$el)
  18. instance = null
  19. }
  20. instance = new Constructor({
  21. el: document.createElement('div'),
  22. router,
  23. computed: {
  24. $store () { return store }
  25. },
  26. i18n,
  27. data () {
  28. return {
  29. visible: false,
  30. userId
  31. }
  32. }
  33. })
  34. document.body.appendChild(instance.$el)
  35. }
  36. }
  37. export default otherInfo