install.js 585 B

123456789101112131415161718192021222324252627282930
  1. import Vue from 'vue'
  2. import Main from './main.vue'
  3. const UploadDashboardConstructor = Vue.extend(Main)
  4. export default {
  5. install (Vue) {
  6. Vue.prototype.$showUpload = showUpload
  7. Vue.prototype.$closeUpload = closeUpload
  8. }
  9. }
  10. let instance
  11. export function showUpload () {
  12. if (!instance) {
  13. instance = new UploadDashboardConstructor()
  14. instance.$mount()
  15. document.body.appendChild(instance.$el)
  16. }
  17. return instance
  18. }
  19. export function closeUpload () {
  20. if (instance) {
  21. instance.$destroy()
  22. document.body.removeChild(instance.$el)
  23. instance = null
  24. }
  25. }