index.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import Avatar from './index.vue'
  2. import i18n from '@/util/lang/lang'
  3. Avatar.install = function (Vue, store) {
  4. const Constructor = Vue.extend(Avatar)
  5. let instance
  6. Vue.prototype.$editUserAvatar = (imageUrl = '') => {
  7. if (instance) {
  8. document.body.removeChild(instance.$el)
  9. instance = null
  10. }
  11. instance = new Constructor({
  12. el: document.createElement('div'),
  13. computed: {
  14. $store () { return store }
  15. },
  16. data () {
  17. return {
  18. visible: true,
  19. imageUrl,
  20. isMe: true
  21. }
  22. },
  23. i18n
  24. })
  25. document.body.appendChild(instance.$el)
  26. }
  27. Vue.prototype.$editGroupAvatar = (imageUrl = '') => {
  28. if (instance) {
  29. document.body.removeChild(instance.$el)
  30. instance = null
  31. }
  32. instance = new Constructor({
  33. el: document.createElement('div'),
  34. computed: {
  35. $store () { return store }
  36. },
  37. data () {
  38. return {
  39. visible: true,
  40. imageUrl,
  41. isMe: false
  42. }
  43. },
  44. i18n
  45. })
  46. document.body.appendChild(instance.$el)
  47. }
  48. }
  49. export default Avatar