Skip to content

Commit

Permalink
发布0.2.1版本
Browse files Browse the repository at this point in the history
  • Loading branch information
lyswhut committed Aug 20, 2019
1 parent 5b2a44e commit 2ff0f4b
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 34 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

### 新增
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lx-music-desktop",
"version": "0.2.0",
"version": "0.2.1",
"description": "一个免费的音乐下载助手",
"main": "./dist/electron/main.js",
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions publish/changeLog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### 优化

- 新增歌曲URL存储,当URL无效时才重新获取,以减少接口不稳定的影响

### 修复

- 修复歌曲加载无法加载时自动切换混乱的Bug
- 修复移除列表最后一首歌曲时播放器不停止播放的问题
8 changes: 6 additions & 2 deletions publish/version.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"version": "0.2.0",
"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",
"version": "0.2.1",
"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",
"history": [
{
"version": "0.2.0",
"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"
},
{
"version": "0.1.6",
"desc": "<h3>修复</h3>\n<ul>\n<li>修复列表多选音源限制Bug</li>\n</ul>\n"
Expand Down
8 changes: 5 additions & 3 deletions src/renderer/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default {
},
defaultList: {
handler(n) {
console.log(n)
this.electronStore.set('list.defaultList', n)
},
deep: true,
Expand Down Expand Up @@ -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)
}
},
Expand Down
53 changes: 33 additions & 20 deletions src/renderer/components/core/Player.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -68,7 +69,8 @@ export default {
text: '',
line: 0,
},
retryNum: 0,
delayNextTimeout: null,
// retryNum: 0,
}
},
computed: {
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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':
Expand Down Expand Up @@ -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) {
Expand Down
16 changes: 9 additions & 7 deletions src/renderer/store/modules/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/store/modules/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2ff0f4b

Please sign in to comment.