feat(国王皇后打榜页): 新增图片预加载缓冲动画,并修复切换按钮的显示问题

This commit is contained in:
hzj 2025-12-25 14:33:51 +08:00
parent 268adf5c31
commit 46238542f2

View File

@ -1,6 +1,14 @@
<!-- src/views/Ranking/KingAndQueen/TopList.vue --> <!-- src/views/Ranking/KingAndQueen/TopList.vue -->
<template> <template>
<div class="fullPage"> <div class="fullPage">
<!-- 预加载状态 -->
<div v-if="isLoading" class="loading-container">
<div class="loading-spinner"></div>
<p style="color: #fff">{{ $t('loading') }}...</p>
</div>
<!-- 主要内容 -->
<div v-else>
<div class="bg" :style="{ '--bg-url': `url(${imageUrl('bg')})` }"> <div class="bg" :style="{ '--bg-url': `url(${imageUrl('bg')})` }">
<!-- 状态栏占位区域仅在APP中显示 --> <!-- 状态栏占位区域仅在APP中显示 -->
<div v-if="isInAppEnvironment" style="height: 30px"></div> <div v-if="isInAppEnvironment" style="height: 30px"></div>
@ -127,7 +135,13 @@
<!-- 每周礼物 --> <!-- 每周礼物 -->
<div <div
style="display: flex; justify-content: center; width: 108vw; position: relative; left: -4vw" style="
display: flex;
justify-content: center;
width: 108vw;
position: relative;
left: -4vw;
"
> >
<itemCenter :imgUrl="imageUrl('eventGifts')"> <itemCenter :imgUrl="imageUrl('eventGifts')">
<div style="width: 80%; display: flex; justify-content: space-around; margin-top: 10%"> <div style="width: 80%; display: flex; justify-content: space-around; margin-top: 10%">
@ -348,7 +362,12 @@
> >
<!-- 内容 --> <!-- 内容 -->
<div <div
style="width: 100%; display: flex; justify-content: space-around; margin-top: 16px" style="
width: 100%;
display: flex;
justify-content: space-around;
margin-top: 16px;
"
> >
<div <div
style="width: 40%" style="width: 40%"
@ -652,7 +671,11 @@
width: 22%; width: 22%;
aspect-ratio: 1/1; aspect-ratio: 1/1;
border-radius: 50%; border-radius: 50%;
background: linear-gradient(to bottom, rgba(255, 224, 60, 1), rgba(255, 189, 19, 1)); background: linear-gradient(
to bottom,
rgba(255, 224, 60, 1),
rgba(255, 189, 19, 1)
);
display: flex; display: flex;
justify-content: center; justify-content: center;
@ -733,6 +756,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</template> </template>
<script setup> <script setup>
@ -756,6 +780,9 @@ import borderImg from './components/borderImg.vue'
import itemCenter from '@/components/itemCenter.vue' import itemCenter from '@/components/itemCenter.vue'
import maskLayer from '@/components/MaskLayer.vue' import maskLayer from '@/components/MaskLayer.vue'
//
const isLoading = ref(true)
// OSSURL // OSSURL
const imageUrl = (filename) => getPngUrl('Ranking/KingQueen/', filename) const imageUrl = (filename) => getPngUrl('Ranking/KingQueen/', filename)
@ -763,9 +790,7 @@ const imageUrl = (filename) => getPngUrl('Ranking/KingQueen/', filename)
const connectToAppHandler = async () => { const connectToAppHandler = async () => {
await connectToApp(() => { await connectToApp(() => {
// //
getUserInfo() completePreloading() //
updatePageData() //
preloadCriticalImages() //
}) })
} }
@ -1023,17 +1048,29 @@ const observer = new IntersectionObserver((entries) => {
}) })
// //
const updatePageData = () => { const updatePageData = async () => {
getTopList(kingListParams.value) // //
getTopList(queenListParams.value) // kingList.value = []
getRewardsAndGifts() //top queenList.value = []
getAllTopOne() // kingListCurrent.value = 1
queenListCurrent.value = 1
showKingLoading.value = true
showQueenLoading.value = true
await Promise.all([
getTopList(kingListParams.value), //
getTopList(queenListParams.value), //
getRewardsAndGifts(), //top
getAllTopOne(), //
])
} }
// //
const preloadCriticalImages = () => { const preloadCriticalImages = async () => {
const criticalImages = [ const criticalImages = [
imageUrl('bg'), imageUrl('bg'),
// imageUrl('border-item'), // background-image使v-smart-img
// imageUrl('border-item-user'), // background-image使v-smart-img
imageUrl('help'), imageUrl('help'),
imageUrl('history'), imageUrl('history'),
imageUrl('listTitle'), imageUrl('listTitle'),
@ -1046,9 +1083,7 @@ const preloadCriticalImages = () => {
imageUrl('queenBt'), imageUrl('queenBt'),
imageUrl('kingBt'), imageUrl('kingBt'),
imageUrl('queenBtActive'), imageUrl('queenBtActive'),
imageUrl('border-item-user'),
imageUrl('helpInfo'), imageUrl('helpInfo'),
imageUrl('border-item'),
imageUrl('timeBack'), imageUrl('timeBack'),
imageUrl('timeNext'), imageUrl('timeNext'),
imageUrl('cancel'), imageUrl('cancel'),
@ -1060,7 +1095,20 @@ const preloadCriticalImages = () => {
imageUrl('top3'), imageUrl('top3'),
] ]
preloadImages(criticalImages) await preloadImages(criticalImages)
}
//
const completePreloading = async () => {
try {
//
await Promise.all([getUserInfo(), updatePageData(), preloadCriticalImages()])
} catch (error) {
console.error('预加载过程中发生错误:', error)
} finally {
//
isLoading.value = false
}
} }
// //
@ -1116,6 +1164,36 @@ onUnmounted(() => {
font-weight: 860; font-weight: 860;
} }
/* 添加加载动画样式 */
.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;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@media screen and (max-width: 360px) { @media screen and (max-width: 360px) {
* { * {
font-size: 10px; font-size: 10px;