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. i18n,
  17. data () {
  18. return {
  19. visible: true,
  20. imageUrl,
  21. isMe: true
  22. }
  23. }
  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. i18n,
  38. data () {
  39. return {
  40. visible: true,
  41. imageUrl,
  42. isMe: false
  43. }
  44. }
  45. })
  46. document.body.appendChild(instance.$el)
  47. }
  48. }
  49. export default Avatar