From aa0a289f27cb10440bcc3e1e8f65f0d2332cc5fc Mon Sep 17 00:00:00 2001 From: 15233722133 <15233722133@163.com> Date: Mon, 1 Jun 2026 11:14:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BC=80=E5=B1=8F=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/startPage.vue | 53 ++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/pages/index/startPage.vue b/pages/index/startPage.vue index 115b670..4ccff6c 100644 --- a/pages/index/startPage.vue +++ b/pages/index/startPage.vue @@ -20,6 +20,7 @@ @loadedmetadata="onVideoMetadata" @canplay="onVideoReady" @play="onVideoReady" + @timeupdate="onVideoTimeUpdate" @ended="onVideoEnded" @click="onMediaClick" /> @@ -33,10 +34,10 @@ @click="onMediaClick" /> - {{ `跳过 ${countDown}s` }} + {{ getSkipText() }} - {{ `跳过 ${countDown}s` }} + {{ getSkipText() }} @@ -47,7 +48,7 @@ import * as IndexApi from '@/sheep/api/index/index' const USE_STATIC_START_PAGE = false const DEFAULT_IMAGE_SECONDS = 3 -const MAX_VIDEO_SECONDS = 15 +const MAX_VIDEO_SECONDS = 9 const bgSrc = ref('') const jumpUrl = ref('') @@ -57,6 +58,7 @@ let downloadToken = 0 let readyFallbackTimer = null let countDownTimer = null let jumpTimer = null +let videoCountdownBootTimer = null const normalizeAppFileUrl = (path) => { const p = String(path || '') @@ -127,7 +129,12 @@ function onMediaError() { startCountDown(DEFAULT_IMAGE_SECONDS) } -const countDown = ref(DEFAULT_IMAGE_SECONDS) +const countDown = ref(0) + +const getSkipText = () => { + const s = Number(countDown.value) || 0 + return s > 0 ? `跳过 ${s}s` : '跳过' +} function closeNativeSplashIfNeeded() { try { @@ -144,6 +151,8 @@ function clearTimers() { countDownTimer = null if (jumpTimer) clearTimeout(jumpTimer) jumpTimer = null + if (videoCountdownBootTimer) clearTimeout(videoCountdownBootTimer) + videoCountdownBootTimer = null } function startCountDown(seconds) { @@ -182,13 +191,21 @@ function onVideoReady() { mediaReady.value = true closeNativeSplashIfNeeded() } - if (!countDownTimer) { + if (countDownTimer) return + if (videoCountdownBootTimer) return + videoCountdownBootTimer = setTimeout(() => { + videoCountdownBootTimer = null + if (countDownTimer) return startCountDown(MAX_VIDEO_SECONDS) scheduleJumpAfter(MAX_VIDEO_SECONDS + 0.2) - } + }, 300) } function onVideoMetadata(e) { + if (videoCountdownBootTimer) { + clearTimeout(videoCountdownBootTimer) + videoCountdownBootTimer = null + } if (!mediaReady.value) { mediaReady.value = true closeNativeSplashIfNeeded() @@ -199,6 +216,20 @@ function onVideoMetadata(e) { scheduleJumpAfter(limit + 0.2) } +function onVideoTimeUpdate(e) { + const duration = Number(e?.detail?.duration || e?.detail?.totalTime || 0) + if (!Number.isFinite(duration) || duration <= 0) return + const limit = Math.min(MAX_VIDEO_SECONDS, Math.ceil(duration)) + if (countDown.value === limit) return + if (countDownTimer && countDown.value < MAX_VIDEO_SECONDS) return + if (videoCountdownBootTimer) { + clearTimeout(videoCountdownBootTimer) + videoCountdownBootTimer = null + } + startCountDown(limit) + scheduleJumpAfter(limit + 0.2) +} + function onVideoEnded() { toHome() } @@ -274,18 +305,22 @@ function onMediaClick() { position: absolute; top: calc(env(safe-area-inset-top) + 100rpx); right: 60rpx; - padding: 18rpx 20rpx; + height: 64rpx; + padding: 0 20rpx; border-radius: 50rpx; font-size: 28rpx; - line-height: 1; + line-height: 32rpx; color: #fff; background: rgba(0, 0, 0, 0.4); z-index: 9999; + display: flex; + align-items: center; + justify-content: center; } .count-down-text { color: #fff; font-size: 28rpx; - line-height: 1; + line-height: 32rpx; }