发布0.2.1版本

pull/96/head v0.2.1
lyswhut 2019-08-20 21:28:06 +08:00
parent 5b2a44e3bd
commit 2ff0f4b102
8 changed files with 76 additions and 34 deletions

View File

@ -6,6 +6,17 @@ Project versioning adheres to [Semantic Versioning](http://semver.org/).
Commit convention is based on [Conventional Commits](http://conventionalcommits.org). Commit convention is based on [Conventional Commits](http://conventionalcommits.org).
Change log format is based on [Keep a Changelog](http://keepachangelog.com/). 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 ## [0.2.0](https://github.com/lyswhut/lx-music-desktop/compare/v0.1.6...v0.2.0) - 2019-08-20
### 新增 ### 新增

View File

@ -1,6 +1,6 @@
{ {
"name": "lx-music-desktop", "name": "lx-music-desktop",
"version": "0.2.0", "version": "0.2.1",
"description": "一个免费的音乐下载助手", "description": "一个免费的音乐下载助手",
"main": "./dist/electron/main.js", "main": "./dist/electron/main.js",
"scripts": { "scripts": {

View File

@ -0,0 +1,8 @@
### 优化
- 新增歌曲URL存储当URL无效时才重新获取以减少接口不稳定的影响
### 修复
- 修复歌曲加载无法加载时自动切换混乱的Bug
- 修复移除列表最后一首歌曲时播放器不停止播放的问题

View File

@ -1,7 +1,11 @@
{ {
"version": "0.2.0", "version": "0.2.1",
"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", "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": [ "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", "version": "0.1.6",
"desc": "<h3>修复</h3>\n<ul>\n<li>修复列表多选音源限制Bug</li>\n</ul>\n" "desc": "<h3>修复</h3>\n<ul>\n<li>修复列表多选音源限制Bug</li>\n</ul>\n"

View File

@ -53,6 +53,7 @@ export default {
}, },
defaultList: { defaultList: {
handler(n) { handler(n) {
console.log(n)
this.electronStore.set('list.defaultList', n) this.electronStore.set('list.defaultList', n)
}, },
deep: true, deep: true,
@ -110,10 +111,11 @@ export default {
}, },
initPlayList() { initPlayList() {
let defaultList = this.electronStore.get('list.defaultList') let defaultList = this.electronStore.get('list.defaultList')
console.log(defaultList)
if (defaultList) { if (defaultList) {
defaultList.list.forEach(m => { // defaultList.list.forEach(m => {
m.typeUrl = {} // m.typeUrl = {}
}) // })
this.initDefaultList(defaultList) this.initDefaultList(defaultList)
} }
}, },

View File

@ -43,6 +43,7 @@ import Lyric from 'lrc-file-parser'
import { rendererSend } from '../../../common/icp' import { rendererSend } from '../../../common/icp'
import { formatPlayTime2, getRandom, checkPath } from '../../utils' import { formatPlayTime2, getRandom, checkPath } from '../../utils'
import { mapGetters, mapActions, mapMutations } from 'vuex' import { mapGetters, mapActions, mapMutations } from 'vuex'
import { requestMsg } from '../../utils/message'
export default { export default {
data() { data() {
@ -68,7 +69,8 @@ export default {
text: '', text: '',
line: 0, line: 0,
}, },
retryNum: 0, delayNextTimeout: null,
// retryNum: 0,
} }
}, },
computed: { computed: {
@ -119,8 +121,13 @@ export default {
? n.findIndex(s => s.musicInfo.songmid === this.musicInfo.songmid) ? n.findIndex(s => s.musicInfo.songmid === this.musicInfo.songmid)
: n.findIndex(s => s.songmid === this.musicInfo.songmid) : n.findIndex(s => s.songmid === this.musicInfo.songmid)
if (index < 0) { if (index < 0) {
this.fixPlayIndex(this.playIndex - 1) // console.log(this.playIndex)
if (n.length) this.handleNext() if (n.length) {
this.fixPlayIndex(this.playIndex - 1)
this.handleNext()
} else {
this.setPlayIndex(-1)
}
} else { } else {
this.fixPlayIndex(index) this.fixPlayIndex(index)
} }
@ -167,7 +174,7 @@ export default {
// console.log('code', this.audio.error.code) // console.log('code', this.audio.error.code)
if (!this.musicInfo.songmid) return if (!this.musicInfo.songmid) return
console.log('出错') console.log('出错')
if (this.audio.error.code == 4 && this.retryNum < 5) { if (this.audio.error.code == 4 && this.retryNum < 3) { // URL3URL
// console.log(this.retryNum) // console.log(this.retryNum)
this.retryNum++ this.retryNum++
this.setUrl(this.list[this.playIndex], true) this.setUrl(this.list[this.playIndex], true)
@ -191,10 +198,8 @@ export default {
// } else { // } else {
// this.handleNext() // this.handleNext()
// } // }
this.status = '音频加载出错2 两秒后切换下一首' this.status = '音频加载出错5 秒后切换下一首'
setTimeout(() => { this.addDelayNextTimeout()
this.handleNext()
}, 2000)
}) })
this.audio.addEventListener('loadeddata', () => { this.audio.addEventListener('loadeddata', () => {
this.maxPlayTime = this.audio.duration this.maxPlayTime = this.audio.duration
@ -241,6 +246,7 @@ export default {
}, },
play() { play() {
console.log('play', this.playIndex) console.log('play', this.playIndex)
this.checkDelayNextTimeout()
let targetSong = this.targetSong = this.list[this.playIndex] let targetSong = this.targetSong = this.list[this.playIndex]
this.retryNum = 0 this.retryNum = 0
@ -264,6 +270,20 @@ export default {
this.setLrc(targetSong) 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() { handleNext() {
// if (this.list.listName === null) return // if (this.list.listName === null) return
let list let list
@ -276,7 +296,7 @@ export default {
} }
if (!list.length) return this.setPlayIndex(-1) if (!list.length) return this.setPlayIndex(-1)
let playIndex = this.list === list ? this.playIndex : list.indexOf(this.list[this.playIndex]) let playIndex = this.list === list ? this.playIndex : list.indexOf(this.list[this.playIndex])
console.log(playIndex)
let index let index
switch (this.setting.player.togglePlayMethod) { switch (this.setting.player.togglePlayMethod) {
case 'listLoop': case 'listLoop':
@ -349,19 +369,12 @@ export default {
this.musicInfo.url = targetSong.typeUrl[type] this.musicInfo.url = targetSong.typeUrl[type]
this.status = '歌曲链接获取中...' this.status = '歌曲链接获取中...'
let urlP = this.musicInfo.url && !isRefresh this.getUrl({ musicInfo: targetSong, type, isRefresh }).then(() => {
? Promise.resolve() this.audio.src = this.musicInfo.url = targetSong.typeUrl[type]
: this.getUrl({ musicInfo: targetSong, type }).then(() => {
this.musicInfo.url = targetSong.typeUrl[type]
})
urlP.then(() => {
this.audio.src = this.musicInfo.url
}).catch(err => { }).catch(err => {
if (err.message == requestMsg.cancelRequest) return
this.status = err.message this.status = err.message
setTimeout(() => { this.addDelayNextTimeout()
this.handleNext()
}, 2000)
}) })
}, },
setImg(targetSong) { setImg(targetSong) {

View File

@ -70,8 +70,9 @@ const addTask = (list, type, store) => {
}) })
} }
const refreshUrl = downloadInfo => { const getUrl = (downloadInfo, isRefresh) => {
return music[downloadInfo.musicInfo.source].getMusicUrl(downloadInfo.musicInfo, downloadInfo.type).promise const url = downloadInfo.musicInfo.typeUrl[downloadInfo.type]
return url && !isRefresh ? Promise.resolve({ url }) : music[downloadInfo.musicInfo.source].getMusicUrl(downloadInfo.musicInfo, downloadInfo.type).promise
} }
// actions // actions
@ -137,15 +138,15 @@ const actions = {
console.log('on complate') console.log('on complate')
}, },
onError(err) { onError(err) {
console.log(err.message) console.log(err.code, err.message)
commit('onError', downloadInfo) commit('onError', downloadInfo)
// console.log(tryNum[downloadInfo.key]) // console.log(tryNum[downloadInfo.key])
if (++tryNum[downloadInfo.key] > 5) return if (++tryNum[downloadInfo.key] > 5) return
let code let code
if (err.message.includes('Response status was')) { if (err.message.includes('Response status was')) {
code = err.message.replace(/Response status was (\d+)$/, '$1') code = err.message.replace(/Response status was (\d+)$/, '$1')
} if (err.code === 'ETIMEDOUT') { } else if (err.code === 'ETIMEDOUT' || err.code == 'ENOTFOUND') {
code = 'ETIMEDOUT' code = err.code
} else { } else {
console.log('Download failed, Attempting Retry') console.log('Download failed, Attempting Retry')
dls[downloadInfo.key].resume() dls[downloadInfo.key].resume()
@ -157,8 +158,9 @@ const actions = {
case '403': case '403':
case '410': case '410':
case 'ETIMEDOUT': case 'ETIMEDOUT':
case 'ENOTFOUND':
commit('setStatusText', { downloadInfo, text: '链接失效,正在刷新链接' }) commit('setStatusText', { downloadInfo, text: '链接失效,正在刷新链接' })
refreshUrl(downloadInfo).then(result => { getUrl(downloadInfo, true).then(result => {
commit('updateUrl', { downloadInfo, url: result.url }) commit('updateUrl', { downloadInfo, url: result.url })
commit('setStatusText', { downloadInfo, text: '链接刷新成功' }) commit('setStatusText', { downloadInfo, text: '链接刷新成功' })
dls[downloadInfo.key].url = dls[downloadInfo.key].requestURL = result.url dls[downloadInfo.key].url = dls[downloadInfo.key].requestURL = result.url
@ -192,7 +194,7 @@ const actions = {
}, },
} }
commit('setStatusText', { downloadInfo, text: '获取URL中...' }) 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 }) commit('updateUrl', { downloadInfo, url: result.url })
if (!result.url) return Promise.reject(new Error('获取URL失败')) if (!result.url) return Promise.reject(new Error('获取URL失败'))
options.url = result.url options.url = result.url

View File

@ -22,8 +22,9 @@ const getters = {
// actions // actions
const actions = { const actions = {
getUrl({ commit, state }, { musicInfo, type }) { getUrl({ commit, state }, { musicInfo, type, isRefresh }) {
if (urlRequest && urlRequest.cancelHttp) urlRequest.cancelHttp() if (urlRequest && urlRequest.cancelHttp) urlRequest.cancelHttp()
if (musicInfo.typeUrl[type] && !isRefresh) return Promise.resolve()
urlRequest = music[musicInfo.source].getMusicUrl(musicInfo, type) urlRequest = music[musicInfo.source].getMusicUrl(musicInfo, type)
return urlRequest.promise.then(result => { return urlRequest.promise.then(result => {
commit('setUrl', { musicInfo, url: result.url, type }) commit('setUrl', { musicInfo, url: result.url, type })
@ -72,6 +73,7 @@ const mutations = {
setPlayIndex(state, index) { setPlayIndex(state, index) {
state.playIndex = index state.playIndex = index
state.changePlay = true state.changePlay = true
// console.log(state.changePlay)
}, },
fixPlayIndex(state, index) { fixPlayIndex(state, index) {
state.playIndex = index state.playIndex = index