优化歌单、排行榜一键播放按钮的播放机制

This commit is contained in:
lyswhut
2021-12-23 15:28:01 +08:00
parent 469a88f368
commit 3ff0dbb7ef
6 changed files with 91 additions and 18 deletions
+26 -4
View File
@@ -58,6 +58,7 @@ div(:class="$style.container")
import { mapGetters, mapMutations, mapActions } from 'vuex'
import { scrollTo } from '@renderer/utils'
import TagList from './components/TagList'
import { tempList } from '@renderer/core/share/list'
export default {
name: 'SongList',
components: {
@@ -181,6 +182,7 @@ export default {
...mapMutations('list', ['listAdd', 'listAddMultiple', 'createUserList']),
...mapMutations('player', {
setTempList: 'setTempList',
updateTempList: 'updateTempList',
setTempPlayList: 'setTempPlayList',
}),
listenEvent() {
@@ -295,12 +297,32 @@ export default {
},
async playSongListDetail() {
if (!this.listDetail.info.name) return
const id = `${this.listDetail.source}__${this.listDetail.id}`
let isPlayingList = false
if (this.listDetail.list?.length) {
this.setTempList({
list: [...this.listDetail.list],
index: 0,
id,
})
isPlayingList = true
}
const list = await this.fetchList()
if (!list.length) return
this.setTempList({
list,
index: 0,
})
if (isPlayingList) {
if (tempList.meta.id == id) {
this.updateTempList({
list,
id,
})
}
} else {
this.setTempList({
list,
index: 0,
id,
})
}
},
},
}