feat: 没有设置开屏页不展示跳过按钮直接展示首页

This commit is contained in:
2026-06-02 15:49:43 +08:00
parent fe1ca06827
commit 04fd017fb0
+66 -20
View File
@@ -33,11 +33,18 @@
@load="onImageLoaded"
@click="onMediaClick"
/>
<cover-view v-if="!USE_STATIC_START_PAGE && bgSrc && isVideo" class="count-down" @click.stop="toHome">
<cover-view class="count-down-text">{{ getSkipText() }}</cover-view>
</cover-view>
<view v-else class="count-down" @click.stop="toHome">
{{ getSkipText() }}
<view
v-if="(USE_STATIC_START_PAGE || bgSrc) && mediaReady && countDown > 0"
class="count-down"
@click.stop="toHome"
>
<text class="count-down-text">{{ getSkipText() }}</text>
</view>
<view v-if="!USE_STATIC_START_PAGE && isLoading" class="loading-mask">
<view class="loading-box">
<view class="loading-spinner"></view>
<view class="loading-text">加载中...</view>
</view>
</view>
</view>
</template>
@@ -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);
}
}
</style>