Skip to content

Commit dc7f011

Browse files
committed
🐞 fix: 修复下一曲播放
1 parent ce67e74 commit dc7f011

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/utils/player.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,11 +796,20 @@ class Player {
796796
return;
797797
}
798798
// 尝试添加
799+
const currentSongId = musicStore.playSong.id;
799800
const songIndex = await dataStore.setNextPlaySong(song, statusStore.playIndex);
800801
// 播放歌曲
801802
if (songIndex < 0) return;
802-
if (play) this.togglePlayIndex(songIndex, true);
803-
else window.$message.success("已添加至下一首播放");
803+
if (play) {
804+
this.togglePlayIndex(songIndex, true);
805+
} else {
806+
// 修正当前播放索引
807+
const newCurrentIndex = dataStore.playList.findIndex((s) => s.id === currentSongId);
808+
if (newCurrentIndex !== -1 && newCurrentIndex !== statusStore.playIndex) {
809+
statusStore.playIndex = newCurrentIndex;
810+
}
811+
window.$message.success("已添加至下一首播放");
812+
}
804813
}
805814
/**
806815
* 切换播放索引

0 commit comments

Comments
 (0)