mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-05 17:38:55 +08:00
优化歌词自动换源机制
This commit is contained in:
parent
78b3f27c36
commit
83c8ff99e1
@ -1,6 +1,7 @@
|
|||||||
### 优化
|
### 优化
|
||||||
|
|
||||||
- 添加应用初始化出错时的错误捕获输出
|
- 添加应用初始化出错时的错误捕获输出
|
||||||
|
- 优化歌词自动换源机制
|
||||||
|
|
||||||
### 修复
|
### 修复
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ export default {
|
|||||||
let requestObj = this.searchLyric(songInfo.name, songInfo.hash, songInfo._interval || this.getIntv(songInfo.interval))
|
let requestObj = this.searchLyric(songInfo.name, songInfo.hash, songInfo._interval || this.getIntv(songInfo.interval))
|
||||||
|
|
||||||
requestObj.promise = requestObj.promise.then(result => {
|
requestObj.promise = requestObj.promise.then(result => {
|
||||||
if (!result) return { lyric: null, tlyric: null, lxlyric: null }
|
if (!result) return Promise.reject(new Error('Get lyric failed'))
|
||||||
|
|
||||||
let requestObj2 = this.getLyricDownload(result.id, result.accessKey)
|
let requestObj2 = this.getLyricDownload(result.id, result.accessKey)
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ export default {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
requestObj.promise = requestObj.promise.then(({ body }) => {
|
requestObj.promise = requestObj.promise.then(({ body }) => {
|
||||||
if (body.returnCode !== '000000') {
|
if (body.returnCode !== '000000' || !body.lyric) {
|
||||||
if (tryNum > 5) return Promise.reject('歌词获取失败')
|
if (tryNum > 5) return Promise.reject(new Error('Get lyric failed'))
|
||||||
let tryRequestObj = this.getLyric(songInfo, ++tryNum)
|
let tryRequestObj = this.getLyric(songInfo, ++tryNum)
|
||||||
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
||||||
return tryRequestObj.promise
|
return tryRequestObj.promise
|
||||||
|
@ -12,7 +12,7 @@ export default {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
requestObj.promise = requestObj.promise.then(({ body }) => {
|
requestObj.promise = requestObj.promise.then(({ body }) => {
|
||||||
if (body.code != 0) return Promise.reject(new Error('获取歌词失败'))
|
if (body.code != 0 || !body.lyric) return Promise.reject(new Error('Get lyric failed'))
|
||||||
return {
|
return {
|
||||||
lyric: decodeName(b64DecodeUnicode(body.lyric)),
|
lyric: decodeName(b64DecodeUnicode(body.lyric)),
|
||||||
tlyric: decodeName(b64DecodeUnicode(body.trans)),
|
tlyric: decodeName(b64DecodeUnicode(body.trans)),
|
||||||
|
@ -50,7 +50,7 @@ export default songmid => {
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
requestObj.promise = requestObj.promise.then(({ body }) => {
|
requestObj.promise = requestObj.promise.then(({ body }) => {
|
||||||
if (body.code !== 200) return Promise.reject('获取歌词失败')
|
if (body.code !== 200 || !body?.lrc?.lyric) return Promise.reject(new Error('Get lyric failed'))
|
||||||
return {
|
return {
|
||||||
lyric: body.lrc.lyric,
|
lyric: body.lrc.lyric,
|
||||||
tlyric: body.tlyric.lyric,
|
tlyric: body.tlyric.lyric,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user