index.js 1.1 KB

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