Skip to content

Commit 2ff0f4b

Browse files
committed
发布0.2.1版本
1 parent 5b2a44e commit 2ff0f4b

8 files changed

Lines changed: 76 additions & 34 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ Project versioning adheres to [Semantic Versioning](http://semver.org/).
66
Commit convention is based on [Conventional Commits](http://conventionalcommits.org).
77
Change log format is based on [Keep a Changelog](http://keepachangelog.com/).
88

9+
## [0.2.1](https://github.com/lyswhut/lx-music-desktop/compare/v0.2.0...v0.2.1) - 2019-08-20
10+
11+
### 优化
12+
13+
- 新增歌曲URL存储,当URL无效时才重新获取,以减少接口不稳定的影响
14+
15+
### 修复
16+
17+
- 修复歌曲加载无法加载时自动切换混乱的Bug
18+
- 修复移除列表最后一首歌曲时播放器不停止播放的问题
19+
920
## [0.2.0](https://github.com/lyswhut/lx-music-desktop/compare/v0.1.6...v0.2.0) - 2019-08-20
1021

1122
### 新增

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lx-music-desktop",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "一个免费的音乐下载助手",
55
"main": "./dist/electron/main.js",
66
"scripts": {

publish/changeLog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### 优化
2+
3+
- 新增歌曲URL存储,当URL无效时才重新获取,以减少接口不稳定的影响
4+
5+
### 修复
6+
7+
- 修复歌曲加载无法加载时自动切换混乱的Bug
8+
- 修复移除列表最后一首歌曲时播放器不停止播放的问题

publish/version.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
2-
"version": "0.2.0",
3-
"desc": "<h3>新增</h3>\n<ul>\n<li>新增<strong>百度音乐</strong>排行榜及其音乐直接试听与下载</li>\n<li>新增网易云排行榜音乐直接试听与下载(目前仅支持128k音质)</li>\n<li>新增酷狗排行榜音乐直接试听与下载(目前仅支持128k音质)</li>\n</ul>\n<h3>修复</h3>\n<ul>\n<li>修复更新弹窗历史版本描述多余的换行问题</li>\n<li>修复歌曲无法播放的情况下歌词仍会播放的问题</li>\n</ul>\n",
2+
"version": "0.2.1",
3+
"desc": "<h3>优化</h3>\n<ul>\n<li>新增歌曲URL存储,当URL无效时才重新获取,以减少接口不稳定的影响</li>\n</ul>\n<h3>修复</h3>\n<ul>\n<li>修复歌曲加载无法加载时自动切换混乱的Bug</li>\n<li>修复移除列表最后一首歌曲时播放器不停止播放的问题</li>\n</ul>\n",
44
"history": [
5+
{
6+
"version": "0.2.0",
7+
"desc": "<h3>新增</h3>\n<ul>\n<li>新增<strong>百度音乐</strong>排行榜及其音乐直接试听与下载</li>\n<li>新增网易云排行榜音乐直接试听与下载(目前仅支持128k音质)</li>\n<li>新增酷狗排行榜音乐直接试听与下载(目前仅支持128k音质)</li>\n</ul>\n<h3>修复</h3>\n<ul>\n<li>修复更新弹窗历史版本描述多余的换行问题</li>\n<li>修复歌曲无法播放的情况下歌词仍会播放的问题</li>\n</ul>\n"
8+
},
59
{
610
"version": "0.1.6",
711
"desc": "<h3>修复</h3>\n<ul>\n<li>修复列表多选音源限制Bug</li>\n</ul>\n"

src/renderer/App.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export default {
5353
},
5454
defaultList: {
5555
handler(n) {
56+
console.log(n)
5657
this.electronStore.set('list.defaultList', n)
5758
},
5859
deep: true,
@@ -110,10 +111,11 @@ export default {
110111
},
111112
initPlayList() {
112113
let defaultList = this.electronStore.get('list.defaultList')
114+
console.log(defaultList)
113115
if (defaultList) {
114-
defaultList.list.forEach(m => {
115-
m.typeUrl = {}
116-
})
116+
// defaultList.list.forEach(m => {
117+
// m.typeUrl = {}
118+
// })
117119
this.initDefaultList(defaultList)
118120
}
119121
},

src/renderer/components/core/Player.vue

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import Lyric from 'lrc-file-parser'
4343
import { rendererSend } from '../../../common/icp'
4444
import { formatPlayTime2, getRandom, checkPath } from '../../utils'
4545
import { mapGetters, mapActions, mapMutations } from 'vuex'
46+
import { requestMsg } from '../../utils/message'
4647
4748
export default {
4849
data() {
@@ -68,7 +69,8 @@ export default {
6869
text: '',
6970
line: 0,
7071
},
71-
retryNum: 0,
72+
delayNextTimeout: null,
73+
// retryNum: 0,
7274
}
7375
},
7476
computed: {
@@ -119,8 +121,13 @@ export default {
119121
? n.findIndex(s => s.musicInfo.songmid === this.musicInfo.songmid)
120122
: n.findIndex(s => s.songmid === this.musicInfo.songmid)
121123
if (index < 0) {
122-
this.fixPlayIndex(this.playIndex - 1)
123-
if (n.length) this.handleNext()
124+
// console.log(this.playIndex)
125+
if (n.length) {
126+
this.fixPlayIndex(this.playIndex - 1)
127+
this.handleNext()
128+
} else {
129+
this.setPlayIndex(-1)
130+
}
124131
} else {
125132
this.fixPlayIndex(index)
126133
}
@@ -167,7 +174,7 @@ export default {
167174
// console.log('code', this.audio.error.code)
168175
if (!this.musicInfo.songmid) return
169176
console.log('出错')
170-
if (this.audio.error.code == 4 && this.retryNum < 5) {
177+
if (this.audio.error.code == 4 && this.retryNum < 3) { // 若音频URL无效则尝试刷新3次URL
171178
// console.log(this.retryNum)
172179
this.retryNum++
173180
this.setUrl(this.list[this.playIndex], true)
@@ -191,10 +198,8 @@ export default {
191198
// } else {
192199
// this.handleNext()
193200
// }
194-
this.status = '音频加载出错,2 两秒后切换下一首'
195-
setTimeout(() => {
196-
this.handleNext()
197-
}, 2000)
201+
this.status = '音频加载出错,5 秒后切换下一首'
202+
this.addDelayNextTimeout()
198203
})
199204
this.audio.addEventListener('loadeddata', () => {
200205
this.maxPlayTime = this.audio.duration
@@ -241,6 +246,7 @@ export default {
241246
},
242247
play() {
243248
console.log('play', this.playIndex)
249+
this.checkDelayNextTimeout()
244250
let targetSong = this.targetSong = this.list[this.playIndex]
245251
this.retryNum = 0
246252
@@ -264,6 +270,20 @@ export default {
264270
this.setLrc(targetSong)
265271
}
266272
},
273+
checkDelayNextTimeout() {
274+
console.log(this.delayNextTimeout)
275+
if (this.delayNextTimeout) {
276+
clearTimeout(this.delayNextTimeout)
277+
this.delayNextTimeout = null
278+
}
279+
},
280+
addDelayNextTimeout() {
281+
this.checkDelayNextTimeout()
282+
this.delayNextTimeout = setTimeout(() => {
283+
this.delayNextTimeout = null
284+
this.handleNext()
285+
}, 5000)
286+
},
267287
handleNext() {
268288
// if (this.list.listName === null) return
269289
let list
@@ -276,7 +296,7 @@ export default {
276296
}
277297
if (!list.length) return this.setPlayIndex(-1)
278298
let playIndex = this.list === list ? this.playIndex : list.indexOf(this.list[this.playIndex])
279-
299+
console.log(playIndex)
280300
let index
281301
switch (this.setting.player.togglePlayMethod) {
282302
case 'listLoop':
@@ -349,19 +369,12 @@ export default {
349369
this.musicInfo.url = targetSong.typeUrl[type]
350370
this.status = '歌曲链接获取中...'
351371
352-
let urlP = this.musicInfo.url && !isRefresh
353-
? Promise.resolve()
354-
: this.getUrl({ musicInfo: targetSong, type }).then(() => {
355-
this.musicInfo.url = targetSong.typeUrl[type]
356-
})
357-
358-
urlP.then(() => {
359-
this.audio.src = this.musicInfo.url
372+
this.getUrl({ musicInfo: targetSong, type, isRefresh }).then(() => {
373+
this.audio.src = this.musicInfo.url = targetSong.typeUrl[type]
360374
}).catch(err => {
375+
if (err.message == requestMsg.cancelRequest) return
361376
this.status = err.message
362-
setTimeout(() => {
363-
this.handleNext()
364-
}, 2000)
377+
this.addDelayNextTimeout()
365378
})
366379
},
367380
setImg(targetSong) {

src/renderer/store/modules/download.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ const addTask = (list, type, store) => {
7070
})
7171
}
7272

73-
const refreshUrl = downloadInfo => {
74-
return music[downloadInfo.musicInfo.source].getMusicUrl(downloadInfo.musicInfo, downloadInfo.type).promise
73+
const getUrl = (downloadInfo, isRefresh) => {
74+
const url = downloadInfo.musicInfo.typeUrl[downloadInfo.type]
75+
return url && !isRefresh ? Promise.resolve({ url }) : music[downloadInfo.musicInfo.source].getMusicUrl(downloadInfo.musicInfo, downloadInfo.type).promise
7576
}
7677

7778
// actions
@@ -137,15 +138,15 @@ const actions = {
137138
console.log('on complate')
138139
},
139140
onError(err) {
140-
console.log(err.message)
141+
console.log(err.code, err.message)
141142
commit('onError', downloadInfo)
142143
// console.log(tryNum[downloadInfo.key])
143144
if (++tryNum[downloadInfo.key] > 5) return
144145
let code
145146
if (err.message.includes('Response status was')) {
146147
code = err.message.replace(/Response status was (\d+)$/, '$1')
147-
} if (err.code === 'ETIMEDOUT') {
148-
code = 'ETIMEDOUT'
148+
} else if (err.code === 'ETIMEDOUT' || err.code == 'ENOTFOUND') {
149+
code = err.code
149150
} else {
150151
console.log('Download failed, Attempting Retry')
151152
dls[downloadInfo.key].resume()
@@ -157,8 +158,9 @@ const actions = {
157158
case '403':
158159
case '410':
159160
case 'ETIMEDOUT':
161+
case 'ENOTFOUND':
160162
commit('setStatusText', { downloadInfo, text: '链接失效,正在刷新链接' })
161-
refreshUrl(downloadInfo).then(result => {
163+
getUrl(downloadInfo, true).then(result => {
162164
commit('updateUrl', { downloadInfo, url: result.url })
163165
commit('setStatusText', { downloadInfo, text: '链接刷新成功' })
164166
dls[downloadInfo.key].url = dls[downloadInfo.key].requestURL = result.url
@@ -192,7 +194,7 @@ const actions = {
192194
},
193195
}
194196
commit('setStatusText', { downloadInfo, text: '获取URL中...' })
195-
let p = options.url ? Promise.resolve() : refreshUrl(downloadInfo).then(result => {
197+
let p = options.url ? Promise.resolve() : getUrl(downloadInfo).then(result => {
196198
commit('updateUrl', { downloadInfo, url: result.url })
197199
if (!result.url) return Promise.reject(new Error('获取URL失败'))
198200
options.url = result.url

src/renderer/store/modules/player.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ const getters = {
2222

2323
// actions
2424
const actions = {
25-
getUrl({ commit, state }, { musicInfo, type }) {
25+
getUrl({ commit, state }, { musicInfo, type, isRefresh }) {
2626
if (urlRequest && urlRequest.cancelHttp) urlRequest.cancelHttp()
27+
if (musicInfo.typeUrl[type] && !isRefresh) return Promise.resolve()
2728
urlRequest = music[musicInfo.source].getMusicUrl(musicInfo, type)
2829
return urlRequest.promise.then(result => {
2930
commit('setUrl', { musicInfo, url: result.url, type })
@@ -72,6 +73,7 @@ const mutations = {
7273
setPlayIndex(state, index) {
7374
state.playIndex = index
7475
state.changePlay = true
76+
// console.log(state.changePlay)
7577
},
7678
fixPlayIndex(state, index) {
7779
state.playIndex = index

0 commit comments

Comments
 (0)