mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-25 08:47:22 +08:00
✨ feat: 优化歌单歌曲播放处理
This commit is contained in:
@@ -421,45 +421,21 @@ const loadFullPlaylist = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 处理播放
|
// 处理播放
|
||||||
const handlePlay = async (item: any) => {
|
const handlePlay = async () => {
|
||||||
// 当搜索状态下播放时,只播放过滤后的歌曲
|
// 当搜索状态下播放时,只播放过滤后的歌曲
|
||||||
if (searchKeyword.value) {
|
if (searchKeyword.value) {
|
||||||
playerStore.setPlayList(filteredSongs.value.map(formatSong));
|
playerStore.setPlayList(filteredSongs.value.map(formatSong));
|
||||||
// 设置当前歌曲为点击的歌曲
|
|
||||||
if (item) {
|
|
||||||
const index = filteredSongs.value.findIndex((song) => song.id === item.id);
|
|
||||||
if (index !== -1) {
|
|
||||||
// 直接播放对应的歌曲
|
|
||||||
playerStore.setPlay(filteredSongs.value[index]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果完整播放列表已加载完成
|
// 如果完整播放列表已加载完成
|
||||||
if (isFullPlaylistLoaded.value && completePlaylist.value.length > 0) {
|
if (isFullPlaylistLoaded.value && completePlaylist.value.length > 0) {
|
||||||
playerStore.setPlayList(completePlaylist.value.map(formatSong));
|
playerStore.setPlayList(completePlaylist.value.map(formatSong));
|
||||||
// 设置当前歌曲为点击的歌曲
|
|
||||||
if (item) {
|
|
||||||
const index = completePlaylist.value.findIndex((song) => song.id === item.id);
|
|
||||||
if (index !== -1) {
|
|
||||||
// 直接播放对应的歌曲
|
|
||||||
playerStore.setPlay(completePlaylist.value[index]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果完整播放列表未加载完成,先使用当前已加载的歌曲开始播放
|
// 如果完整播放列表未加载完成,先使用当前已加载的歌曲开始播放
|
||||||
playerStore.setPlayList(displayedSongs.value.map(formatSong));
|
playerStore.setPlayList(displayedSongs.value.map(formatSong));
|
||||||
// 设置当前歌曲为点击的歌曲
|
|
||||||
if (item) {
|
|
||||||
const index = displayedSongs.value.findIndex((song) => song.id === item.id);
|
|
||||||
if (index !== -1) {
|
|
||||||
// 直接播放对应的歌曲
|
|
||||||
playerStore.setPlay(displayedSongs.value[index]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果完整播放列表正在加载中,不需要重新触发加载
|
// 如果完整播放列表正在加载中,不需要重新触发加载
|
||||||
if (isPlaylistLoading.value) {
|
if (isPlaylistLoading.value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user