fix: 修复随机播放模式 手动下一首不是随机的问题

This commit is contained in:
alger
2025-03-04 19:29:46 +08:00
parent dfd5d4c8b7
commit fb35d42fc4

View File

@@ -156,7 +156,20 @@ export const useMusicListHook = () => {
state.play = true;
return;
}
const playListIndex = (state.playListIndex + 1) % state.playList.length;
let playListIndex: number;
if (state.playMode === 2) {
// 随机播放模式
do {
playListIndex = Math.floor(Math.random() * state.playList.length);
} while (playListIndex === state.playListIndex && state.playList.length > 1);
} else {
// 列表循环模式
playListIndex = (state.playListIndex + 1) % state.playList.length;
}
state.playListIndex = playListIndex;
await handlePlayMusic(state, state.playList[playListIndex]);
};