refactor(AudioPlayer): 调整播放列表弹出层样式和行为
将播放列表弹出层的样式和行为进行优化,包括调整高度、添加遮罩层以及在选择歌曲后自动关闭播放列表
Showing
2 changed files
with
8 additions
and
6 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-04-07 12:35:35 | 2 | * @Date: 2025-04-07 12:35:35 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-04-07 17:20:54 | 4 | + * @LastEditTime: 2025-04-07 17:37:34 |
| 5 | * @FilePath: /mlaj/src/components/ui/audioPlayer.vue | 5 | * @FilePath: /mlaj/src/components/ui/audioPlayer.vue |
| 6 | * @Description: 音频播放器组件,支持播放控制、进度条调节、音量控制、播放列表等功能 | 6 | * @Description: 音频播放器组件,支持播放控制、进度条调节、音量控制、播放列表等功能 |
| 7 | --> | 7 | --> |
| ... | @@ -81,12 +81,13 @@ | ... | @@ -81,12 +81,13 @@ |
| 81 | 81 | ||
| 82 | <!-- 播放列表弹出层 --> | 82 | <!-- 播放列表弹出层 --> |
| 83 | <van-popup | 83 | <van-popup |
| 84 | + teleport="body" | ||
| 84 | v-model:show="isPlaylistVisible" | 85 | v-model:show="isPlaylistVisible" |
| 85 | position="bottom" | 86 | position="bottom" |
| 86 | - :overlay="false" | 87 | + :overlay="true" |
| 87 | round | 88 | round |
| 88 | class="playlist-popup" | 89 | class="playlist-popup" |
| 89 | - style="height: 100%" | 90 | + style="height: 70vh" |
| 90 | > | 91 | > |
| 91 | <div class="playlist-header flex justify-between items-center px-4 py-3 border-b sticky top-0 bg-white z-10"> | 92 | <div class="playlist-header flex justify-between items-center px-4 py-3 border-b sticky top-0 bg-white z-10"> |
| 92 | <h4 class="font-medium">播放列表 ({{ songs.length }})</h4> | 93 | <h4 class="font-medium">播放列表 ({{ songs.length }})</h4> |
| ... | @@ -158,7 +159,6 @@ onMounted(() => { | ... | @@ -158,7 +159,6 @@ onMounted(() => { |
| 158 | const loadAudio = async () => { | 159 | const loadAudio = async () => { |
| 159 | if (!currentSong.value) return | 160 | if (!currentSong.value) return |
| 160 | isLoading.value = true | 161 | isLoading.value = true |
| 161 | - isPlaylistVisible.value = false // 关闭播放列表 | ||
| 162 | try { | 162 | try { |
| 163 | if (audio.value) { | 163 | if (audio.value) { |
| 164 | audio.value.removeEventListener('timeupdate', updateProgress) | 164 | audio.value.removeEventListener('timeupdate', updateProgress) |
| ... | @@ -306,6 +306,8 @@ const selectSong = async (index) => { | ... | @@ -306,6 +306,8 @@ const selectSong = async (index) => { |
| 306 | if (audio.value) { | 306 | if (audio.value) { |
| 307 | await audio.value.play() | 307 | await audio.value.play() |
| 308 | isPlaying.value = true | 308 | isPlaying.value = true |
| 309 | + // 关闭播放列表 | ||
| 310 | + isPlaylistVisible.value = false | ||
| 309 | // 滚动到当前播放的音频 | 311 | // 滚动到当前播放的音频 |
| 310 | const playlistItems = document.querySelector('.playlist-items') | 312 | const playlistItems = document.querySelector('.playlist-items') |
| 311 | const activeItem = playlistItems?.querySelector('.active') | 313 | const activeItem = playlistItems?.querySelector('.active') | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-03-24 13:04:21 | 2 | * @Date: 2025-03-24 13:04:21 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-04-07 17:17:52 | 4 | + * @LastEditTime: 2025-04-07 17:58:02 |
| 5 | * @FilePath: /mlaj/src/views/profile/settings/AudioPlayerPage.vue | 5 | * @FilePath: /mlaj/src/views/profile/settings/AudioPlayerPage.vue |
| 6 | * @Description: 音频播放页面 | 6 | * @Description: 音频播放页面 |
| 7 | --> | 7 | --> |
| ... | @@ -37,7 +37,7 @@ const audioList = ref([ | ... | @@ -37,7 +37,7 @@ const audioList = ref([ |
| 37 | title: '示例音频 2', | 37 | title: '示例音频 2', |
| 38 | artist: '演唱者 2', | 38 | artist: '演唱者 2', |
| 39 | cover: 'https://cdn.ipadbiz.cn/mlaj/images/zMRLZh40kms.jpg', | 39 | cover: 'https://cdn.ipadbiz.cn/mlaj/images/zMRLZh40kms.jpg', |
| 40 | - url: 'https://img.tukuppt.com/newpreview_music/09/03/72/5c8ad96fbf47328809.mp3' | 40 | + url: 'https://img.tukuppt.com/newpreview_music/08/99/00/5c88d4a8d1f5745026.mp3' |
| 41 | }, | 41 | }, |
| 42 | { | 42 | { |
| 43 | id: 3, | 43 | id: 3, | ... | ... |
-
Please register or login to post a comment