From 04fd017fb0e9b2e560d61e7212dfeee2fd9c041d Mon Sep 17 00:00:00 2001 From: 15233722133 <15233722133@163.com> Date: Tue, 2 Jun 2026 15:49:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B2=A1=E6=9C=89=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=BC=80=E5=B1=8F=E9=A1=B5=E4=B8=8D=E5=B1=95=E7=A4=BA=E8=B7=B3?= =?UTF-8?q?=E8=BF=87=E6=8C=89=E9=92=AE=E7=9B=B4=E6=8E=A5=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E9=A6=96=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/startPage.vue | 86 ++++++++++++++++++++++++++++++--------- 1 file changed, 66 insertions(+), 20 deletions(-) diff --git a/pages/index/startPage.vue b/pages/index/startPage.vue index 4ccff6c..f6e89e2 100644 --- a/pages/index/startPage.vue +++ b/pages/index/startPage.vue @@ -33,11 +33,18 @@ @load="onImageLoaded" @click="onMediaClick" /> - - {{ getSkipText() }} - - - {{ getSkipText() }} + + {{ getSkipText() }} + + + + + 加载中... + @@ -54,6 +61,7 @@ const bgSrc = ref('') const jumpUrl = ref('') const isVideo = ref(false) const mediaReady = ref(false) +const isLoading = ref(false) let downloadToken = 0 let readyFallbackTimer = null let countDownTimer = null @@ -123,10 +131,7 @@ const fetchStartPage = async () => { } function onMediaError() { - bgSrc.value = '' - isVideo.value = false - mediaReady.value = false - startCountDown(DEFAULT_IMAGE_SECONDS) + toHome() } const countDown = ref(0) @@ -181,6 +186,7 @@ function scheduleJumpAfter(seconds) { function onImageLoaded() { if (mediaReady.value) return mediaReady.value = true + isLoading.value = false closeNativeSplashIfNeeded() startCountDown(DEFAULT_IMAGE_SECONDS) scheduleJumpAfter(DEFAULT_IMAGE_SECONDS + 0.2) @@ -189,6 +195,7 @@ function onImageLoaded() { function onVideoReady() { if (!mediaReady.value) { mediaReady.value = true + isLoading.value = false closeNativeSplashIfNeeded() } if (countDownTimer) return @@ -208,6 +215,7 @@ function onVideoMetadata(e) { } if (!mediaReady.value) { mediaReady.value = true + isLoading.value = false closeNativeSplashIfNeeded() } const duration = Number(e?.detail?.duration || e?.detail?.totalTime || 0) @@ -241,22 +249,16 @@ onMounted(() => { scheduleJumpAfter(DEFAULT_IMAGE_SECONDS + 0.2) return } + isLoading.value = true fetchStartPage().then((ok) => { if (!ok) { - closeNativeSplashIfNeeded() - startCountDown(DEFAULT_IMAGE_SECONDS) - scheduleJumpAfter(DEFAULT_IMAGE_SECONDS + 0.2) + toHome() return } readyFallbackTimer = setTimeout(() => { - if (countDownTimer) return - if (isVideo.value) { - onVideoReady() - return - } - startCountDown(DEFAULT_IMAGE_SECONDS) - scheduleJumpAfter(DEFAULT_IMAGE_SECONDS + 0.2) - }, isVideo.value ? 2500 : 1200) + if (mediaReady.value) return + toHome() + }, isVideo.value ? 3500 : 2000) }) }) @@ -266,6 +268,7 @@ onUnmounted(() => { function toHome() { clearTimers() + isLoading.value = false uni.reLaunch({ url: '/pages/index/index', }) @@ -323,4 +326,47 @@ function onMediaClick() { font-size: 28rpx; line-height: 32rpx; } + +.loading-mask { + position: absolute; + inset: 0; + z-index: 9998; + display: flex; + align-items: center; + justify-content: center; + background: rgba(255, 255, 255, 0.1); +} + +.loading-box { + padding: 22rpx 26rpx; + border-radius: 16rpx; + background: rgba(0, 0, 0, 0.45); + display: flex; + align-items: center; + gap: 16rpx; +} + +.loading-spinner { + width: 32rpx; + height: 32rpx; + border-radius: 50%; + border: 4rpx solid rgba(255, 255, 255, 0.35); + border-top-color: rgba(255, 255, 255, 0.95); + animation: spin 0.85s linear infinite; +} + +.loading-text { + font-size: 26rpx; + color: #fff; + line-height: 32rpx; +} + +@keyframes spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +}