1、loading页增加背景颜色,同时压缩loading_bg图片
2、点击开始按钮时,检测并进行音乐播放
3、调整视频播放关闭按钮位置
This commit is contained in:
Wenzhe 2026-02-04 14:54:29 +08:00
parent f58436e0fe
commit 3ed1978442
5 changed files with 51 additions and 30 deletions

View File

@ -137,6 +137,7 @@ onMounted(() => {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
z-index: 9999; z-index: 9999;
background-color: #fd4336;
} }
.loading-bg { .loading-bg {

View File

@ -234,6 +234,12 @@ const handleStart = () => {
hasScrolled.value = false hasScrolled.value = false
console.log('点击开始按钮hasScrolled:', hasScrolled.value) console.log('点击开始按钮hasScrolled:', hasScrolled.value)
//
if (!isMusicPlaying.value) {
console.log('背景音乐未播放,开始播放')
toggleMusic()
}
// //
initPage() initPage()
} }
@ -330,9 +336,27 @@ const toggleMusic = () => {
console.log('音乐已暂停') console.log('音乐已暂停')
} else { } else {
// //
audioPlayer.value.play() try {
const result = audioPlayer.value.play()
// play()PromiseWeb
if (result && typeof result.then === 'function') {
// Web使Promise
result.then(() => {
isMusicPlaying.value = true isMusicPlaying.value = true
console.log('音乐已开始播放') console.log('音乐已开始播放')
}).catch(error => {
console.error('音乐播放失败(需要用户交互):', error)
// isMusicPlayingfalse
})
} else {
//
isMusicPlaying.value = true
console.log('音乐已开始播放')
}
} catch (error) {
console.error('音乐播放失败(需要用户交互):', error)
// isMusicPlayingfalse
}
} }
} }
@ -343,10 +367,8 @@ onMounted(() => {
// //
initMusicPlayer() initMusicPlayer()
// //
setTimeout(() => { //
toggleMusic()
}, 1000)
}) })
// //

View File

@ -63,7 +63,7 @@ const handlePlayClick = () => {
/* 鼠标悬停效果 */ /* 鼠标悬停效果 */
.video-play-button-container:hover .video-play-button-bg { .video-play-button-container:hover .video-play-button-bg {
background-color: rgba(0, 0, 0, 0.9); background-color: rgba(0, 0, 0, 0.4);
transform: scale(1.05); transform: scale(1.05);
animation: none; animation: none;
} }

View File

@ -37,9 +37,6 @@ const handleContentClick = (e) => {
<template> <template>
<div v-if="visible" class="video-modal"> <div v-if="visible" class="video-modal">
<div class="video-modal-content" @click="handleContentClick"> <div class="video-modal-content" @click="handleContentClick">
<div class="video-close-button" @click="handleClose">
<span>×</span>
</div>
<video <video
:src="videoUrl" :src="videoUrl"
class="video-player" class="video-player"
@ -48,6 +45,10 @@ const handleContentClick = (e) => {
loop loop
></video> ></video>
</div> </div>
<!-- 关闭按钮放在视频下方 -->
<div class="video-close-button" @click="handleClose">
<img src="/static/images/btn_close.png" alt="关闭" class="close-icon" />
</div>
</div> </div>
</template> </template>
@ -63,6 +64,7 @@ const handleContentClick = (e) => {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
flex-direction: column;
z-index: 999; z-index: 999;
} }
@ -70,18 +72,22 @@ const handleContentClick = (e) => {
position: relative; position: relative;
border-radius: 20rpx; border-radius: 20rpx;
overflow: hidden; overflow: hidden;
width: 720rpx;
display: flex;
flex-direction: column;
align-items: center;
}
.video-player {
width: 720rpx; width: 720rpx;
height: 405rpx; height: 405rpx;
background-color: #000;
} }
.video-close-button { .video-close-button {
position: absolute; margin-top: 30rpx;
top: 10rpx; width: 68rpx;
right: 10rpx; height: 68rpx;
width: 40rpx;
height: 40rpx;
background-color: rgba(0, 0, 0, 0.7);
border-radius: 50%;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
@ -89,17 +95,9 @@ const handleContentClick = (e) => {
z-index: 10; z-index: 10;
} }
.video-close-button span { .close-icon {
color: white; width: 68rpx;
font-size: 30rpx; height: 68rpx;
font-weight: bold; object-fit: contain;
line-height: 30rpx;
height: 30rpx;
}
.video-player {
width: 100%;
height: 100%;
background-color: #000;
} }
</style> </style>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 41 KiB