diff --git a/CHANGELOG.md b/CHANGELOG.md
index d4e8602e47..7c2d72c61c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,17 @@ Project versioning adheres to [Semantic Versioning](http://semver.org/).
Commit convention is based on [Conventional Commits](http://conventionalcommits.org).
Change log format is based on [Keep a Changelog](http://keepachangelog.com/).
+## [0.2.1](https://github.com/lyswhut/lx-music-desktop/compare/v0.2.0...v0.2.1) - 2019-08-20
+
+### 优化
+
+- 新增歌曲URL存储,当URL无效时才重新获取,以减少接口不稳定的影响
+
+### 修复
+
+- 修复歌曲加载无法加载时自动切换混乱的Bug
+- 修复移除列表最后一首歌曲时播放器不停止播放的问题
+
## [0.2.0](https://github.com/lyswhut/lx-music-desktop/compare/v0.1.6...v0.2.0) - 2019-08-20
### 新增
diff --git a/package.json b/package.json
index fa9c8d438b..fd67fd81c7 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "lx-music-desktop",
- "version": "0.2.0",
+ "version": "0.2.1",
"description": "一个免费的音乐下载助手",
"main": "./dist/electron/main.js",
"scripts": {
diff --git a/publish/changeLog.md b/publish/changeLog.md
index e69de29bb2..55f7660847 100644
--- a/publish/changeLog.md
+++ b/publish/changeLog.md
@@ -0,0 +1,8 @@
+### 优化
+
+- 新增歌曲URL存储,当URL无效时才重新获取,以减少接口不稳定的影响
+
+### 修复
+
+- 修复歌曲加载无法加载时自动切换混乱的Bug
+- 修复移除列表最后一首歌曲时播放器不停止播放的问题
diff --git a/publish/version.json b/publish/version.json
index 199a9336c4..2816d83969 100644
--- a/publish/version.json
+++ b/publish/version.json
@@ -1,7 +1,11 @@
{
- "version": "0.2.0",
- "desc": "
新增
\n\n- 新增百度音乐排行榜及其音乐直接试听与下载
\n- 新增网易云排行榜音乐直接试听与下载(目前仅支持128k音质)
\n- 新增酷狗排行榜音乐直接试听与下载(目前仅支持128k音质)
\n
\n修复
\n\n- 修复更新弹窗历史版本描述多余的换行问题
\n- 修复歌曲无法播放的情况下歌词仍会播放的问题
\n
\n",
+ "version": "0.2.1",
+ "desc": "优化
\n\n- 新增歌曲URL存储,当URL无效时才重新获取,以减少接口不稳定的影响
\n
\n修复
\n\n- 修复歌曲加载无法加载时自动切换混乱的Bug
\n- 修复移除列表最后一首歌曲时播放器不停止播放的问题
\n
\n",
"history": [
+ {
+ "version": "0.2.0",
+ "desc": "新增
\n\n- 新增百度音乐排行榜及其音乐直接试听与下载
\n- 新增网易云排行榜音乐直接试听与下载(目前仅支持128k音质)
\n- 新增酷狗排行榜音乐直接试听与下载(目前仅支持128k音质)
\n
\n修复
\n\n- 修复更新弹窗历史版本描述多余的换行问题
\n- 修复歌曲无法播放的情况下歌词仍会播放的问题
\n
\n"
+ },
{
"version": "0.1.6",
"desc": "修复
\n\n"
diff --git a/src/renderer/App.vue b/src/renderer/App.vue
index 79f4566baf..d1e9f932c5 100644
--- a/src/renderer/App.vue
+++ b/src/renderer/App.vue
@@ -53,6 +53,7 @@ export default {
},
defaultList: {
handler(n) {
+ console.log(n)
this.electronStore.set('list.defaultList', n)
},
deep: true,
@@ -110,10 +111,11 @@ export default {
},
initPlayList() {
let defaultList = this.electronStore.get('list.defaultList')
+ console.log(defaultList)
if (defaultList) {
- defaultList.list.forEach(m => {
- m.typeUrl = {}
- })
+ // defaultList.list.forEach(m => {
+ // m.typeUrl = {}
+ // })
this.initDefaultList(defaultList)
}
},
diff --git a/src/renderer/components/core/Player.vue b/src/renderer/components/core/Player.vue
index dd551a684c..67e5168cd5 100644
--- a/src/renderer/components/core/Player.vue
+++ b/src/renderer/components/core/Player.vue
@@ -43,6 +43,7 @@ import Lyric from 'lrc-file-parser'
import { rendererSend } from '../../../common/icp'
import { formatPlayTime2, getRandom, checkPath } from '../../utils'
import { mapGetters, mapActions, mapMutations } from 'vuex'
+import { requestMsg } from '../../utils/message'
export default {
data() {
@@ -68,7 +69,8 @@ export default {
text: '',
line: 0,
},
- retryNum: 0,
+ delayNextTimeout: null,
+ // retryNum: 0,
}
},
computed: {
@@ -119,8 +121,13 @@ export default {
? n.findIndex(s => s.musicInfo.songmid === this.musicInfo.songmid)
: n.findIndex(s => s.songmid === this.musicInfo.songmid)
if (index < 0) {
- this.fixPlayIndex(this.playIndex - 1)
- if (n.length) this.handleNext()
+ // console.log(this.playIndex)
+ if (n.length) {
+ this.fixPlayIndex(this.playIndex - 1)
+ this.handleNext()
+ } else {
+ this.setPlayIndex(-1)
+ }
} else {
this.fixPlayIndex(index)
}
@@ -167,7 +174,7 @@ export default {
// console.log('code', this.audio.error.code)
if (!this.musicInfo.songmid) return
console.log('出错')
- if (this.audio.error.code == 4 && this.retryNum < 5) {
+ if (this.audio.error.code == 4 && this.retryNum < 3) { // 若音频URL无效则尝试刷新3次URL
// console.log(this.retryNum)
this.retryNum++
this.setUrl(this.list[this.playIndex], true)
@@ -191,10 +198,8 @@ export default {
// } else {
// this.handleNext()
// }
- this.status = '音频加载出错,2 两秒后切换下一首'
- setTimeout(() => {
- this.handleNext()
- }, 2000)
+ this.status = '音频加载出错,5 秒后切换下一首'
+ this.addDelayNextTimeout()
})
this.audio.addEventListener('loadeddata', () => {
this.maxPlayTime = this.audio.duration
@@ -241,6 +246,7 @@ export default {
},
play() {
console.log('play', this.playIndex)
+ this.checkDelayNextTimeout()
let targetSong = this.targetSong = this.list[this.playIndex]
this.retryNum = 0
@@ -264,6 +270,20 @@ export default {
this.setLrc(targetSong)
}
},
+ checkDelayNextTimeout() {
+ console.log(this.delayNextTimeout)
+ if (this.delayNextTimeout) {
+ clearTimeout(this.delayNextTimeout)
+ this.delayNextTimeout = null
+ }
+ },
+ addDelayNextTimeout() {
+ this.checkDelayNextTimeout()
+ this.delayNextTimeout = setTimeout(() => {
+ this.delayNextTimeout = null
+ this.handleNext()
+ }, 5000)
+ },
handleNext() {
// if (this.list.listName === null) return
let list
@@ -276,7 +296,7 @@ export default {
}
if (!list.length) return this.setPlayIndex(-1)
let playIndex = this.list === list ? this.playIndex : list.indexOf(this.list[this.playIndex])
-
+ console.log(playIndex)
let index
switch (this.setting.player.togglePlayMethod) {
case 'listLoop':
@@ -349,19 +369,12 @@ export default {
this.musicInfo.url = targetSong.typeUrl[type]
this.status = '歌曲链接获取中...'
- let urlP = this.musicInfo.url && !isRefresh
- ? Promise.resolve()
- : this.getUrl({ musicInfo: targetSong, type }).then(() => {
- this.musicInfo.url = targetSong.typeUrl[type]
- })
-
- urlP.then(() => {
- this.audio.src = this.musicInfo.url
+ this.getUrl({ musicInfo: targetSong, type, isRefresh }).then(() => {
+ this.audio.src = this.musicInfo.url = targetSong.typeUrl[type]
}).catch(err => {
+ if (err.message == requestMsg.cancelRequest) return
this.status = err.message
- setTimeout(() => {
- this.handleNext()
- }, 2000)
+ this.addDelayNextTimeout()
})
},
setImg(targetSong) {
diff --git a/src/renderer/store/modules/download.js b/src/renderer/store/modules/download.js
index d4d958fd5c..0bc65f1a1a 100644
--- a/src/renderer/store/modules/download.js
+++ b/src/renderer/store/modules/download.js
@@ -70,8 +70,9 @@ const addTask = (list, type, store) => {
})
}
-const refreshUrl = downloadInfo => {
- return music[downloadInfo.musicInfo.source].getMusicUrl(downloadInfo.musicInfo, downloadInfo.type).promise
+const getUrl = (downloadInfo, isRefresh) => {
+ const url = downloadInfo.musicInfo.typeUrl[downloadInfo.type]
+ return url && !isRefresh ? Promise.resolve({ url }) : music[downloadInfo.musicInfo.source].getMusicUrl(downloadInfo.musicInfo, downloadInfo.type).promise
}
// actions
@@ -137,15 +138,15 @@ const actions = {
console.log('on complate')
},
onError(err) {
- console.log(err.message)
+ console.log(err.code, err.message)
commit('onError', downloadInfo)
// console.log(tryNum[downloadInfo.key])
if (++tryNum[downloadInfo.key] > 5) return
let code
if (err.message.includes('Response status was')) {
code = err.message.replace(/Response status was (\d+)$/, '$1')
- } if (err.code === 'ETIMEDOUT') {
- code = 'ETIMEDOUT'
+ } else if (err.code === 'ETIMEDOUT' || err.code == 'ENOTFOUND') {
+ code = err.code
} else {
console.log('Download failed, Attempting Retry')
dls[downloadInfo.key].resume()
@@ -157,8 +158,9 @@ const actions = {
case '403':
case '410':
case 'ETIMEDOUT':
+ case 'ENOTFOUND':
commit('setStatusText', { downloadInfo, text: '链接失效,正在刷新链接' })
- refreshUrl(downloadInfo).then(result => {
+ getUrl(downloadInfo, true).then(result => {
commit('updateUrl', { downloadInfo, url: result.url })
commit('setStatusText', { downloadInfo, text: '链接刷新成功' })
dls[downloadInfo.key].url = dls[downloadInfo.key].requestURL = result.url
@@ -192,7 +194,7 @@ const actions = {
},
}
commit('setStatusText', { downloadInfo, text: '获取URL中...' })
- let p = options.url ? Promise.resolve() : refreshUrl(downloadInfo).then(result => {
+ let p = options.url ? Promise.resolve() : getUrl(downloadInfo).then(result => {
commit('updateUrl', { downloadInfo, url: result.url })
if (!result.url) return Promise.reject(new Error('获取URL失败'))
options.url = result.url
diff --git a/src/renderer/store/modules/player.js b/src/renderer/store/modules/player.js
index c173c66804..d7a66da197 100644
--- a/src/renderer/store/modules/player.js
+++ b/src/renderer/store/modules/player.js
@@ -22,8 +22,9 @@ const getters = {
// actions
const actions = {
- getUrl({ commit, state }, { musicInfo, type }) {
+ getUrl({ commit, state }, { musicInfo, type, isRefresh }) {
if (urlRequest && urlRequest.cancelHttp) urlRequest.cancelHttp()
+ if (musicInfo.typeUrl[type] && !isRefresh) return Promise.resolve()
urlRequest = music[musicInfo.source].getMusicUrl(musicInfo, type)
return urlRequest.promise.then(result => {
commit('setUrl', { musicInfo, url: result.url, type })
@@ -72,6 +73,7 @@ const mutations = {
setPlayIndex(state, index) {
state.playIndex = index
state.changePlay = true
+ // console.log(state.changePlay)
},
fixPlayIndex(state, index) {
state.playIndex = index