App.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { Toast } from 'vant'
  2. import { defineComponent, reactive } from 'vue'
  3. import { Vue3Lottie } from 'vue3-lottie'
  4. import AstronautJSON from '../components/o-full-refresh/datas/data.json'
  5. import baseEvent from '@/base-event'
  6. export default defineComponent({
  7. name: 'App',
  8. setup() {
  9. const state = reactive({
  10. showToast: false,
  11. showToastCenter: false
  12. })
  13. baseEvent.on('toastShow', (type?: string) => {
  14. if (type === 'center') {
  15. state.showToastCenter = true
  16. }
  17. state.showToast = true
  18. })
  19. baseEvent.on('toastClose', (type?: string) => {
  20. state.showToast = false
  21. if (type === 'center') {
  22. setTimeout(() => {
  23. state.showToastCenter = false
  24. }, 300)
  25. }
  26. })
  27. // 查看状态
  28. baseEvent.on('toastStatus', () => {
  29. return state.showToast
  30. })
  31. return () => (
  32. <>
  33. <router-view></router-view>
  34. <div class={['appRootToast', state.showToastCenter ? 'appRootToastCenter' : '']}>
  35. <Toast v-model:show={state.showToast} overlay duration={30000}>
  36. {{
  37. message: () => (
  38. <>
  39. <Vue3Lottie class={'toastAnimate'} animationData={AstronautJSON}></Vue3Lottie>
  40. {/* <p>加载中...</p> */}
  41. </>
  42. )
  43. }}
  44. </Toast>
  45. </div>
  46. </>
  47. )
  48. }
  49. })