| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- <script setup lang="ts">
- import { watch } from 'vue'
- import { useDocumentVisibility } from '@vueuse/core'
- const { refreshUser, isAuthenticated, isInitialized } = useAuth()
- const { handleRechargeCallback } = useRecharge()
- // 页面恢复前台时触发的方法
- const handlePageVisible = () => {
- if (isInitialized.value && isAuthenticated.value) {
- refreshUser()
- }
- }
- // 使用 VueUse 的文档可见性状态
- const visibility = useDocumentVisibility()
- watch(visibility, (state) => {
- if (state === 'visible') {
- handlePageVisible()
- }
- })
- onMounted(() => {
- handleRechargeCallback()
- })
- </script>
- <template>
- <div>
- <slot />
- <PopupOrder />
- <PopupTopup />
- <PopupFindPartner />
- <PopupSelectList />
- <PopupPaybackResult />
- <PopupAbout />
- <PopupIm />
- </div>
- </template>
|