mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-08-04 14:25:48 +08:00
fix(player): 私人 FM 模式下点击下一首按钮可正常切歌
FM 播放列表只保留 1 首,原 _nextPlay 走到"顺序模式 + 最后一首" 分支只弹"列表已播完"提示,仅 audioService end 事件中拉取下一首 FM 的逻辑生效,导致用户手动点击下一首无效(issue #666)。 抽出 _nextFmPlay,_nextPlay 入口检测 isFmPlaying 直接路由到 FM 分支;MusicHook end 事件去掉重复的 FM 处理,统一走 nextPlayOnEnd。
This commit is contained in:
@@ -535,43 +535,12 @@ const setupAudioListeners = () => {
|
||||
if (getPlayerStore().playMode === 1) {
|
||||
// 单曲循环模式
|
||||
replayMusic();
|
||||
} else if (getPlayerStore().isFmPlaying) {
|
||||
// 私人FM模式:自动获取下一首
|
||||
try {
|
||||
const { getPersonalFM } = await import('@/api/home');
|
||||
const res = await getPersonalFM();
|
||||
const songs = res.data?.data;
|
||||
if (Array.isArray(songs) && songs.length > 0) {
|
||||
const song = songs[0];
|
||||
const fmSong = {
|
||||
id: song.id,
|
||||
name: song.name,
|
||||
picUrl: song.al?.picUrl || song.album?.picUrl,
|
||||
ar: song.artists || song.ar,
|
||||
al: song.al || song.album,
|
||||
source: 'netease' as const,
|
||||
song,
|
||||
...song,
|
||||
playLoading: false
|
||||
} as any;
|
||||
const { usePlaylistStore } = await import('@/store/modules/playlist');
|
||||
const playlistStore = usePlaylistStore();
|
||||
playlistStore.setPlayList([fmSong], false, false);
|
||||
getPlayerStore().isFmPlaying = true; // setPlayList 会清除,需重设
|
||||
const { playTrack } = await import('@/services/playbackController');
|
||||
await playTrack(fmSong, true);
|
||||
} else {
|
||||
getPlayerStore().setIsPlay(false);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('FM自动播放下一首失败:', error);
|
||||
getPlayerStore().setIsPlay(false);
|
||||
}
|
||||
} else {
|
||||
// 顺序播放、列表循环、随机播放模式:歌曲自然结束
|
||||
const { usePlaylistStore } = await import('@/store/modules/playlist');
|
||||
usePlaylistStore().nextPlayOnEnd();
|
||||
return;
|
||||
}
|
||||
|
||||
// 其他模式(FM/顺序/列表循环/随机):交给 playlist store 路由
|
||||
const { usePlaylistStore } = await import('@/store/modules/playlist');
|
||||
usePlaylistStore().nextPlayOnEnd();
|
||||
});
|
||||
|
||||
audioService.on('previoustrack', () => {
|
||||
|
||||
Reference in New Issue
Block a user