default.vue 815 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <script setup lang="ts">
  2. import { watch } from 'vue'
  3. import { useDocumentVisibility } from '@vueuse/core'
  4. const { refreshUser, isAuthenticated, isInitialized } = useAuth()
  5. const { handleRechargeCallback } = useRecharge()
  6. // 页面恢复前台时触发的方法
  7. const handlePageVisible = () => {
  8. if (isInitialized.value && isAuthenticated.value) {
  9. refreshUser()
  10. }
  11. }
  12. // 使用 VueUse 的文档可见性状态
  13. const visibility = useDocumentVisibility()
  14. watch(visibility, (state) => {
  15. if (state === 'visible') {
  16. handlePageVisible()
  17. }
  18. })
  19. onMounted(() => {
  20. handleRechargeCallback()
  21. })
  22. </script>
  23. <template>
  24. <div>
  25. <slot />
  26. <PopupOrder />
  27. <PopupTopup />
  28. <PopupFindPartner />
  29. <PopupSelectList />
  30. <PopupPaybackResult />
  31. <PopupAbout />
  32. <PopupIm />
  33. </div>
  34. </template>