diff --git a/src/components/common/SongItem.vue b/src/components/common/SongItem.vue index 7bd180e..e87f06c 100644 --- a/src/components/common/SongItem.vue +++ b/src/components/common/SongItem.vue @@ -71,7 +71,6 @@ const emits = defineEmits(['play']) const playMusicEvent = (item: any) => { store.commit('setPlay', item) store.commit('setIsPlay', true) - store.state.playListIndex = 0 emits('play', item) } diff --git a/src/store/index.ts b/src/store/index.ts index a178a45..888f398 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -50,7 +50,9 @@ const mutations = { state.play = play }, setPlayList(state: State, playList: SongResult[]) { - state.playListIndex = 0 + state.playListIndex = playList.findIndex( + (item) => item.id === state.playMusic.id + ) state.playList = playList }, async nextPlay(state: State) {