index.js 1.1 KB

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