index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { createApp } from 'vue'
  2. import necessaryInfoDialog from './components/necessaryInfoDialog.vue'
  3. import positionAd from './components/positionAd.vue'
  4. import vuetify from '@/plugins/vuetify'
  5. // import { showImprovePersonaInfo } from '@/utils/whiteList'
  6. // import router from '@/router'
  7. const toastMessage = (type, option = {}) => {
  8. // debugger
  9. // if (type === 'necessaryInfoDialog' && router && showImprovePersonaInfo(router.path)) return
  10. return new Promise((resolve, reject) => {
  11. const componentName = type === 'necessaryInfoDialog' ?
  12. necessaryInfoDialog : type === 'positionAd' ?
  13. positionAd : null
  14. //
  15. const rootNode = document.createElement("div")
  16. document.querySelector('.v-application').appendChild(rootNode)
  17. const app = createApp(componentName, {
  18. // title,
  19. // text,
  20. option,
  21. cancel () {
  22. app.unmount()
  23. rootNode.remove()
  24. if (option.cancelCallback) {
  25. reject()
  26. }
  27. },
  28. sure () {
  29. app.unmount()
  30. rootNode.remove()
  31. resolve()
  32. },
  33. other () {
  34. app.unmount()
  35. rootNode.remove()
  36. resolve({ otherClick: true })
  37. }
  38. })
  39. app.use(vuetify)
  40. app.mount(rootNode)
  41. })
  42. }
  43. // 注册插件app.use()会自动执行install函数
  44. toastMessage.install = (app) => {
  45. app.config.globalProperties.Curtain = toastMessage
  46. }
  47. export default toastMessage