Skip to content

Commit 81bd8fb

Browse files
committed
支持启动软件时恢复播放下载列表里的歌曲
1 parent 47ee572 commit 81bd8fb

4 files changed

Lines changed: 45 additions & 15 deletions

File tree

publish/changeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- 优化我的列表、下载列表等列表的滚动流畅度
44
- 优化下载功能的批量添加、删除、暂停任务时的流畅度,现在进行这些操作应该不会再觉得卡顿了
5+
- 支持启动软件时恢复播放下载列表里的歌曲
56

67
### 修复
78

src/renderer/App.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,17 @@ export default {
404404
if (!info) return
405405
if (info.index < 0) return
406406
if (info.listId) {
407-
const list = window.allList[info.listId]
408-
// console.log(list)
409-
if (!list || !list.list[info.index]) return
410-
info.list = list.list
407+
if (info.listId == 'download') {
408+
const list = this.downloadList
409+
// console.log(list)
410+
if (!list || !list[info.index]) return
411+
info.list = list
412+
} else {
413+
const list = window.allList[info.listId]
414+
// console.log(list)
415+
if (!list || !list.list[info.index]) return
416+
info.list = list.list
417+
}
411418
}
412419
if (!info.list || !info.list[info.index]) return
413420
window.restorePlayInfo = info

src/renderer/components/core/Player.vue

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ div(:class="$style.player")
6464
//- transition(enter-active-class="animated lightSpeedIn"
6565
transition(enter-active-class="animated lightSpeedIn"
6666
leave-active-class="animated slideOutDown")
67-
core-player-detail(v-show="isShowPlayerDetail" :visible.sync="isShowPlayerDetail" :musicInfo="currentMusicInfo"
67+
core-player-detail(v-if="isShowPlayerDetail" :visible.sync="isShowPlayerDetail" :musicInfo="currentMusicInfo"
6868
:lyric="lyric" :list="list" :listId="listId"
6969
:playInfo="{ nowPlayTimeStr, maxPlayTimeStr, progress, nowPlayTime, status }"
7070
:isPlay="isPlay" @action="handlePlayDetailAction"
@@ -505,8 +505,6 @@ export default {
505505
this.musicInfo.album = targetSong.albumName
506506
audio.src = filePath
507507
// console.log(filePath)
508-
this.setImg(targetSong)
509-
this.setLrc(targetSong)
510508
} else {
511509
// if (!this.assertApiSupport(targetSong.source)) return this.playNext()
512510
this.currentMusicInfo = targetSong
@@ -515,9 +513,9 @@ export default {
515513
this.musicInfo.name = targetSong.name
516514
this.musicInfo.album = targetSong.albumName
517515
this.setUrl(targetSong)
518-
this.setImg(targetSong)
519-
this.setLrc(targetSong)
520516
}
517+
this.setImg(targetSong)
518+
this.setLrc(targetSong)
521519
this.handleUpdateWinLyricInfo('music_info', {
522520
songmid: this.musicInfo.songmid,
523521
singer: this.musicInfo.singer,
@@ -595,11 +593,25 @@ export default {
595593
window.getComputedStyle(this.$refs.dom_progress, null).width,
596594
)
597595
},
598-
togglePlay() {
596+
async togglePlay() {
599597
if (!audio.src) {
600598
if (this.restorePlayTime != null) {
601-
// if (!this.assertApiSupport(this.targetSong.source)) return this.playNext()
602-
this.setUrl(this.targetSong)
599+
if (this.listId == 'download') {
600+
const filePath = path.join(this.setting.download.savePath, this.targetSong.fileName)
601+
// console.log(filePath)
602+
if (!await checkPath(filePath) || !this.targetSong.isComplate || /\.ape$/.test(filePath)) {
603+
if (this.list.length == 1) {
604+
this.handleRemoveMusic()
605+
} else {
606+
this.playNext()
607+
}
608+
return
609+
}
610+
audio.src = filePath
611+
} else {
612+
// if (!this.assertApiSupport(this.targetSong.source)) return this.playNext()
613+
this.setUrl(this.targetSong)
614+
}
603615
}
604616
return
605617
}
@@ -919,8 +931,18 @@ export default {
919931
if (!this.musicInfo.songmid) return
920932
this.isShowAddMusicTo = true
921933
},
922-
handleRestorePlay(restorePlayInfo) {
923-
let musicInfo = this.list[restorePlayInfo.index]
934+
async handleRestorePlay(restorePlayInfo) {
935+
let musicInfo
936+
937+
if (this.listId == 'download') {
938+
this.currentMusicInfo = musicInfo = window.downloadListFullMap.get(this.list[restorePlayInfo.index].key).musicInfo
939+
// console.log(filePath)
940+
} else {
941+
// if (!this.assertApiSupport(targetSong.source)) return this.playNext()
942+
musicInfo = this.list[restorePlayInfo.index]
943+
this.currentMusicInfo = musicInfo
944+
}
945+
924946
this.musicInfo.songmid = musicInfo.songmid
925947
this.musicInfo.singer = musicInfo.singer
926948
this.musicInfo.name = musicInfo.name

src/renderer/store/modules/player.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ const getters = {
195195
// // musicInfo: state.playMusicInfo.musicInfo,
196196
// })
197197

198-
console.log(state.playMusicInfo)
198+
// console.log(state.playMusicInfo)
199199
return {
200200
listId,
201201
playIndex,

0 commit comments

Comments
 (0)