feat(总排行榜页): 新增图片预加载缓冲动画,并修复切换按钮的显示问题

This commit is contained in:
hzj 2025-12-25 14:54:49 +08:00
parent 46238542f2
commit ffa3b2e3d2
2 changed files with 87 additions and 32 deletions

View File

@ -1,33 +1,39 @@
<!-- src/views/Ranking/Overall/Ranking.vue --> <!-- src/views/Ranking/Overall/Ranking.vue -->
<template> <template>
<div class="fullPage" :style="{ backgroundColor }"> <div class="fullPage" :style="{ backgroundColor }">
<!-- 背景图 --> <!-- 预加载状态 -->
<div style="position: absolute; top: 0; left: 0; width: 100vw; z-index: 3"> <div v-show="isLoading" class="loading-container">
<img <div class="loading-spinner"></div>
v-show="rankingType == 'Wealth'" <p>{{ $t('loading') }}...</p>
v-smart-img
:src="imageUrl('bgWealth')"
alt=""
style="display: block; width: 100%; object-fit: cover"
/>
<img
v-show="rankingType == 'Charm'"
v-smart-img
:src="imageUrl('bgCharm')"
alt=""
style="display: block; width: 100%; object-fit: cover"
/>
<img
v-show="rankingType == 'Room'"
v-smart-img
:src="imageUrl('bgRoom')"
alt=""
style="display: block; width: 100%; object-fit: cover"
/>
</div> </div>
<!-- 主要内容 --> <!-- 主要内容 -->
<div style="position: relative; z-index: 4"> <div v-show="!isLoading" style="position: relative; z-index: 4">
<!-- 背景图 -->
<div style="position: absolute; top: 0; left: 0; width: 100vw; z-index: -1">
<img
v-show="rankingType == 'Wealth'"
v-smart-img
:src="imageUrl('bgWealth')"
alt=""
style="display: block; width: 100%; object-fit: cover"
/>
<img
v-show="rankingType == 'Charm'"
v-smart-img
:src="imageUrl('bgCharm')"
alt=""
style="display: block; width: 100%; object-fit: cover"
/>
<img
v-show="rankingType == 'Room'"
v-smart-img
:src="imageUrl('bgRoom')"
alt=""
style="display: block; width: 100%; object-fit: cover"
/>
</div>
<!-- 哨兵元素 --> <!-- 哨兵元素 -->
<div ref="sentinel"></div> <div ref="sentinel"></div>
@ -284,10 +290,11 @@
</div> </div>
<!-- 我的排名占位 --> <!-- 我的排名占位 -->
<div style="height: 15vw"></div> <div v-if="!isLoading" style="height: 15vw"></div>
<!-- 我的排名 --> <!-- 我的排名 -->
<div <div
v-if="!isLoading"
style="position: fixed; bottom: 0; z-index: 999; padding: 0 1px; width: 100%" style="position: fixed; bottom: 0; z-index: 999; padding: 0 1px; width: 100%"
:style="{ backgroundColor }" :style="{ backgroundColor }"
> >
@ -428,8 +435,11 @@ const totalRanking = ref({})
const showRanking = ref([]) const showRanking = ref([])
const myRanking = ref({}) // const myRanking = ref({}) //
//
const isLoading = ref(true)
// //
const preloadCriticalImages = () => { const preloadCriticalImages = async () => {
const criticalImages = [ const criticalImages = [
imageUrl('bgWealth'), imageUrl('bgWealth'),
imageUrl('bgCharm'), imageUrl('bgCharm'),
@ -443,7 +453,7 @@ const preloadCriticalImages = () => {
imageUrl('top3-room'), imageUrl('top3-room'),
] ]
preloadImages(criticalImages) await preloadImages(criticalImages)
} }
// //
@ -652,17 +662,31 @@ const getMyRankingInfo = async () => {
} }
// //
const initData = () => { const initData = async () => {
getRanking() // await Promise.all([
getMyRankingInfo() // getRanking(), //
getMyRankingInfo(), //
])
}
//
const completePreloading = async () => {
try {
//
await Promise.all([initData(), preloadCriticalImages()])
} catch (error) {
console.error('预加载过程中发生错误:', error)
} finally {
//
isLoading.value = false
}
} }
// 使APP // 使APP
const connectToAppHandler = async () => { const connectToAppHandler = async () => {
await connectToApp(() => { await connectToApp(() => {
// //
initData() // completePreloading() //
preloadCriticalImages() //
}) })
} }
@ -722,6 +746,36 @@ onMounted(() => {
backdrop-filter: blur(32px); backdrop-filter: blur(32px);
} }
/* 添加加载动画样式 */
.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;

View File

@ -68,6 +68,7 @@
<div style="width: 60%; position: relative"> <div style="width: 60%; position: relative">
<img v-smart-img :src="coinNumBgUrl" alt="" width="100%" style="display: block" /> <img v-smart-img :src="coinNumBgUrl" alt="" width="100%" style="display: block" />
<div <div
v-if="distributionValue"
style=" style="
position: absolute; position: absolute;
inset: 0; inset: 0;