index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import Vue from 'vue'
  2. import UILoading from './Loading.vue'
  3. import UIBroadcast from './Broadcast.vue'
  4. import UIMap from './Map.vue'
  5. import UIAlert from './Alert.vue'
  6. const Loading = Vue.extend(UILoading)
  7. const Broadcast = Vue.extend(UIBroadcast)
  8. const Map = Vue.extend(UIMap)
  9. const Alert = Vue.extend(UIAlert)
  10. let alertInstance = ''
  11. export function $showAlert(data={}) {
  12. if (alertInstance) {
  13. return
  14. }
  15. alertInstance = new Alert({
  16. data
  17. }).$mount()
  18. document.body.appendChild(alertInstance.$el)
  19. Vue.nextTick(() => {
  20. alertInstance.show = true
  21. })
  22. }
  23. export function $hideAlert() {
  24. if (alertInstance) {
  25. document.body.removeChild(alertInstance.$el)
  26. alertInstance = ''
  27. }
  28. }
  29. let loadingInstance = ''
  30. export function $showLoading(data={}) {
  31. if (loadingInstance) {
  32. return
  33. }
  34. loadingInstance = new Loading({
  35. data
  36. }).$mount()
  37. document.body.appendChild(loadingInstance.$el)
  38. Vue.nextTick(() => {
  39. loadingInstance.show = true
  40. })
  41. }
  42. export function $hideLoading() {
  43. if (loadingInstance) {
  44. document.body.removeChild(loadingInstance.$el)
  45. loadingInstance = ''
  46. }
  47. }
  48. let broadcastInstance = ''
  49. export function $showBroadcast(data={}) {
  50. if (broadcastInstance) {
  51. return
  52. }
  53. broadcastInstance = new Broadcast({
  54. data
  55. }).$mount()
  56. document.body.appendChild(broadcastInstance.$el)
  57. Vue.nextTick(() => {
  58. broadcastInstance.show = true
  59. })
  60. }
  61. export function $hideBroadcast() {
  62. if (broadcastInstance) {
  63. document.body.removeChild(broadcastInstance.$el)
  64. broadcastInstance = ''
  65. }
  66. }
  67. let mapInstance = ''
  68. export function $showMap(data={}) {
  69. if (mapInstance) {
  70. return
  71. }
  72. mapInstance = new Map({
  73. data
  74. }).$mount()
  75. document.body.appendChild(mapInstance.$el)
  76. Vue.nextTick(() => {
  77. mapInstance.show = true
  78. })
  79. }
  80. export function $hideMap() {
  81. if (mapInstance) {
  82. document.body.removeChild(mapInstance.$el)
  83. mapInstance = ''
  84. }
  85. }