From 268adf5c315bf9f24156db2e4ad889cfeb3b667c Mon Sep 17 00:00:00 2001 From: hzj <1304805162@qq.com> Date: Thu, 25 Dec 2025 14:22:27 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B8=B8=E6=88=8F=E7=8E=8B=E6=89=93?= =?UTF-8?q?=E6=A6=9C=E9=A1=B5):=20=E6=96=B0=E5=A2=9E=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E9=A2=84=E5=8A=A0=E8=BD=BD=E7=BC=93=E5=86=B2=E5=8A=A8=E7=94=BB?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E4=BF=AE=E5=A4=8D=E5=88=87=E6=8D=A2=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E7=9A=84=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Ranking/GamesKing/index.vue | 1081 +++++++++++++------------ 1 file changed, 563 insertions(+), 518 deletions(-) diff --git a/src/views/Ranking/GamesKing/index.vue b/src/views/Ranking/GamesKing/index.vue index c27fd33..9850d35 100644 --- a/src/views/Ranking/GamesKing/index.vue +++ b/src/views/Ranking/GamesKing/index.vue @@ -1,574 +1,579 @@ @@ -591,6 +596,9 @@ import maskLayer from '@/components/MaskLayer.vue' const isInAppEnvironment = ref(false) // 检测是否在APP环境中 const maskLayerShow = ref(false) //帮助模块 +// 预加载状态 +const isLoading = ref(true) + const langStore = useLangStore() // 当前语言类型 const currentLangType = computed(() => { @@ -741,13 +749,15 @@ const getRewardsAndGifts = async () => { } // 刷新页面数据 -const initData = () => { - getListAndMy() // 获取排行榜和我的排名 - getRewardsAndGifts() //获取本周的礼物和奖励列表 +const initData = async () => { + await Promise.all([ + getListAndMy(), // 获取排行榜和我的排名 + getRewardsAndGifts(), //获取本周的礼物和奖励列表 + ]) } // 预加载关键图片 -const preloadCriticalImages = () => { +const preloadCriticalImages = async () => { const criticalImages = [ imageUrl('bg'), imageUrl('bg2'), @@ -803,9 +813,22 @@ const preloadCriticalImages = () => { ] if (currentLangType.value == 'en') { - preloadImages(criticalImages) + await preloadImages(criticalImages) } else if (currentLangType.value == 'ar') { - preloadImages(criticalImages_ar) + await preloadImages(criticalImages_ar) + } +} + +// 完成预加载 +const completePreloading = async () => { + try { + // 执行所有初始化操作 + await Promise.all([initData(), preloadCriticalImages()]) + } catch (error) { + console.error('预加载过程中发生错误:', error) + } finally { + // 无论成功或失败都结束加载状态 + isLoading.value = false } } @@ -813,8 +836,7 @@ const preloadCriticalImages = () => { const connectToAppHandler = async () => { await connectToApp(() => { // 连接成功回调 - initData() //初始化数据 - preloadCriticalImages() //预加载关键图片 + completePreloading() // 完成预加载 }) } @@ -850,17 +872,6 @@ onUnmounted(() => { z-index: 1; } -.ranking-bg { - background-color: #400000; - background-image: var(--ranking-bg-url); - background-size: 100% auto; - background-repeat: no-repeat; - - position: absolute; - inset: 10vw 2% 1vw; - z-index: 1; -} - .timeText { color: #fff; font-weight: 590; @@ -903,6 +914,40 @@ onUnmounted(() => { margin-top: 10vw; } +/* 添加加载动画样式 */ +.loading-container { + width: 100vw; + height: 100vh; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + color: #666; +} + +.loading-spinner { + width: 32px; + height: 32px; + border: 3px solid #f3f3f3; + border-top: 3px solid #f59e0b; + border-radius: 50%; + animation: spin 1s linear infinite; + margin-bottom: 12px; +} + +.toggle-image { + transition: opacity 0.3s ease-in-out; +} + +@keyframes spin { + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(360deg); + } +} + @media screen and (max-width: 360px) { * { font-size: 10px;