GlobalLoading.vue 1008 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <script lang="ts" setup>
  2. const { loadingOptions, currentPage } = storeToRefs(useGlobalLoading())
  3. const { close: closeGlobalLoading } = useGlobalLoading()
  4. const loading = useToast('globalLoading')
  5. const currentPath = getCurrentPath()
  6. // #ifdef MP-ALIPAY
  7. const hackAlipayVisible = ref(false)
  8. nextTick(() => {
  9. hackAlipayVisible.value = true
  10. })
  11. // #endif
  12. watch(() => loadingOptions.value, (newVal) => {
  13. if (newVal && newVal.show) {
  14. if (currentPage.value === currentPath) {
  15. loading.loading(loadingOptions.value)
  16. }
  17. }
  18. else {
  19. loading.close()
  20. }
  21. })
  22. </script>
  23. <script lang="ts">
  24. export default {
  25. options: {
  26. virtualHost: true,
  27. addGlobalClass: true,
  28. styleIsolation: 'shared',
  29. },
  30. }
  31. </script>
  32. <template>
  33. <!-- #ifdef MP-ALIPAY -->
  34. <wd-toast v-if="hackAlipayVisible" selector="globalLoading" :closed="closeGlobalLoading" />
  35. <!-- #endif -->
  36. <!-- #ifndef MP-ALIPAY -->
  37. <wd-toast selector="globalLoading" :closed="closeGlobalLoading" />
  38. <!-- #endif -->
  39. </template>