修复在线音乐列表获取失败时无限循环请求的问题
parent
e4c19c0f2a
commit
914e738931
|
@ -14,6 +14,7 @@
|
||||||
- 修复咪咕源无法搜索的问题
|
- 修复咪咕源无法搜索的问题
|
||||||
- 修复更新弹窗底部文字颜色没有适配当前主题颜色的问题
|
- 修复更新弹窗底部文字颜色没有适配当前主题颜色的问题
|
||||||
- 修复导入设置窗口大小、代理设置不立即生效的问题
|
- 修复导入设置窗口大小、代理设置不立即生效的问题
|
||||||
|
- 修复在线音乐列表获取失败时无限循环请求的问题
|
||||||
|
|
||||||
### 其他
|
### 其他
|
||||||
|
|
||||||
|
|
|
@ -64,14 +64,15 @@ export default {
|
||||||
})
|
})
|
||||||
return list
|
return list
|
||||||
},
|
},
|
||||||
search(str, page = 1, { limit } = {}) {
|
search(str, page = 1, { limit } = {}, retryNum = 0) {
|
||||||
|
if (++retryNum > 3) return Promise.reject(new Error('try max num'))
|
||||||
if (limit != null) this.limit = limit
|
if (limit != null) this.limit = limit
|
||||||
|
|
||||||
return this.musicSearch(str, page).then(result => {
|
return this.musicSearch(str, page).then(result => {
|
||||||
if (!result || result.error_code !== 22000) return this.search(str, page, { limit })
|
if (!result || result.error_code !== 22000) return this.search(str, page, { limit }, retryNum)
|
||||||
let list = this.handleResult(result.result.song_info.song_list)
|
let list = this.handleResult(result.result.song_info.song_list)
|
||||||
|
|
||||||
if (list == null) return this.search(str, page, { limit })
|
if (list == null) return this.search(str, page, { limit }, retryNum)
|
||||||
|
|
||||||
this.total = result.result.song_info.total
|
this.total = result.result.song_info.total
|
||||||
this.page = page
|
this.page = page
|
||||||
|
|
|
@ -68,14 +68,15 @@ export default {
|
||||||
})
|
})
|
||||||
return list
|
return list
|
||||||
},
|
},
|
||||||
search(str, page = 1, { limit } = {}) {
|
search(str, page = 1, { limit } = {}, retryNum = 0) {
|
||||||
|
if (++retryNum > 3) return Promise.reject(new Error('try max num'))
|
||||||
if (limit != null) this.limit = limit
|
if (limit != null) this.limit = limit
|
||||||
// http://newlyric.kuwo.cn/newlyric.lrc?62355680
|
// http://newlyric.kuwo.cn/newlyric.lrc?62355680
|
||||||
return this.musicSearch(str, page).then(result => {
|
return this.musicSearch(str, page).then(result => {
|
||||||
if (!result || result.errcode !== 0) return this.search(str, page, { limit })
|
if (!result || result.errcode !== 0) return this.search(str, page, { limit }, retryNum)
|
||||||
let list = this.handleResult(result.data.info)
|
let list = this.handleResult(result.data.info)
|
||||||
|
|
||||||
if (list == null) return this.search(str, page, { limit })
|
if (list == null) return this.search(str, page, { limit }, retryNum)
|
||||||
|
|
||||||
this.total = result.data.total
|
this.total = result.data.total
|
||||||
this.page = page
|
this.page = page
|
||||||
|
|
|
@ -169,17 +169,18 @@ export default {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
loadData(p1, p2, page, bangid) {
|
loadData(p1, p2, page, bangid, retryNum = 0) {
|
||||||
|
if (++retryNum > 3) return Promise.reject(new Error('try max num'))
|
||||||
return Promise.all([p1, p2]).then(([data1, data2]) => {
|
return Promise.all([p1, p2]).then(([data1, data2]) => {
|
||||||
// console.log(data1, data2)
|
// console.log(data1, data2)
|
||||||
if (!data1.musiclist.length) {
|
if (!data1.musiclist.length) {
|
||||||
return this.loadData(this.getData(this.getUrl(page, this.limit, bangid)),
|
return this.loadData(this.getData(this.getUrl(page, this.limit, bangid)),
|
||||||
data2.data.musicList.length
|
data2.data.musicList.length
|
||||||
? Promise.resolve(data2)
|
? Promise.resolve(data2)
|
||||||
: this.getData2(this.getUrl2(page, this.limit, bangid)), page, bangid)
|
: this.getData2(this.getUrl2(page, this.limit, bangid)), page, bangid, retryNum)
|
||||||
}
|
}
|
||||||
if (!data2.data.musicList.length) {
|
if (!data2.data.musicList.length) {
|
||||||
return this.loadData(Promise.resolve(data1), this.getData2(this.getUrl2(page, this.limit, bangid)), page, bangid)
|
return this.loadData(Promise.resolve(data1), this.getData2(this.getUrl2(page, this.limit, bangid)), page, bangid, retryNum)
|
||||||
}
|
}
|
||||||
return Promise.resolve([data1, data2])
|
return Promise.resolve([data1, data2])
|
||||||
})
|
})
|
||||||
|
|
|
@ -121,11 +121,13 @@ export default {
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
},
|
},
|
||||||
search(str, page = 1, { limit } = {}) {
|
search(str, page = 1, { limit } = {}, retryNum = 0) {
|
||||||
|
if (retryNum > 2) return Promise.reject(new Error('try max num'))
|
||||||
if (limit != null) this.limit = limit
|
if (limit != null) this.limit = limit
|
||||||
// http://newlyric.kuwo.cn/newlyric.lrc?62355680
|
// http://newlyric.kuwo.cn/newlyric.lrc?62355680
|
||||||
return this.musicSearch(str, page).then(result => {
|
return this.musicSearch(str, page).then(result => {
|
||||||
if (!result || (result.TOTAL !== '0' && result.SHOW === '0')) return this.search(str, page, { limit })
|
if (!result || (result.TOTAL !== '0' && result.SHOW === '0')) return this.search(str, page, { limit }, ++retryNum)
|
||||||
|
console.log(result)
|
||||||
let list = this.handleResult(result.abslist)
|
let list = this.handleResult(result.abslist)
|
||||||
|
|
||||||
if (list == null) return this.search(str, page, { limit })
|
if (list == null) return this.search(str, page, { limit })
|
||||||
|
|
|
@ -93,7 +93,7 @@ export default {
|
||||||
this._requestObj_list = httpFetch(this.getListUrl({ sortId, id, type, page }))
|
this._requestObj_list = httpFetch(this.getListUrl({ sortId, id, type, page }))
|
||||||
return this._requestObj_list.promise.then(({ body }) => {
|
return this._requestObj_list.promise.then(({ body }) => {
|
||||||
if (!id || type == '10000') {
|
if (!id || type == '10000') {
|
||||||
if (body.code !== this.successCode) return this.getList(sortId, id, type, page, ++tryNum)
|
if (body.code !== this.successCode) return this.getList(sortId, tagId, page, ++tryNum)
|
||||||
return {
|
return {
|
||||||
list: this.filterList(body.data.data),
|
list: this.filterList(body.data.data),
|
||||||
total: body.data.total,
|
total: body.data.total,
|
||||||
|
|
|
@ -110,7 +110,8 @@ export default {
|
||||||
})
|
})
|
||||||
return list
|
return list
|
||||||
},
|
},
|
||||||
search(str, page = 1, { limit } = {}) {
|
search(str, page = 1, { limit } = {}, retryNum = 0) {
|
||||||
|
if (++retryNum > 3) return Promise.reject(new Error('try max num'))
|
||||||
if (limit != null) this.limit = limit
|
if (limit != null) this.limit = limit
|
||||||
// http://newlyric.kuwo.cn/newlyric.lrc?62355680
|
// http://newlyric.kuwo.cn/newlyric.lrc?62355680
|
||||||
return this.musicSearch(str, page).then(result => {
|
return this.musicSearch(str, page).then(result => {
|
||||||
|
@ -118,7 +119,7 @@ export default {
|
||||||
if (!result || result.success !== true) return Promise.reject(new Error(result ? result.info : '搜索失败'))
|
if (!result || result.success !== true) return Promise.reject(new Error(result ? result.info : '搜索失败'))
|
||||||
let list = result.musics ? this.handleResult(result.musics) : []
|
let list = result.musics ? this.handleResult(result.musics) : []
|
||||||
|
|
||||||
if (list == null) return this.search(str, page, { limit })
|
if (list == null) return this.search(str, page, { limit }, retryNum)
|
||||||
|
|
||||||
this.total = parseInt(result.pgt)
|
this.total = parseInt(result.pgt)
|
||||||
this.page = page
|
this.page = page
|
||||||
|
|
|
@ -77,14 +77,15 @@ export default {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
search(str, page = 1, { limit } = {}) {
|
search(str, page = 1, { limit } = {}, retryNum = 0) {
|
||||||
|
if (++retryNum > 3) return Promise.reject(new Error('try max num'))
|
||||||
if (limit != null) this.limit = limit
|
if (limit != null) this.limit = limit
|
||||||
return this.musicSearch(str, page).then(result => {
|
return this.musicSearch(str, page).then(result => {
|
||||||
// console.log(JSON.stringify(result))
|
// console.log(JSON.stringify(result))
|
||||||
if (!result || result.code !== 200) return this.search(str, page, { limit })
|
if (!result || result.code !== 200) return this.search(str, page, { limit }, retryNum)
|
||||||
let list = this.handleResult(result.result.songs)
|
let list = this.handleResult(result.result.songs)
|
||||||
|
|
||||||
if (list == null) return this.search(str, page, { limit })
|
if (list == null) return this.search(str, page, { limit }, retryNum)
|
||||||
|
|
||||||
this.total = result.result.songCount
|
this.total = result.result.songCount
|
||||||
this.page = page
|
this.page = page
|
||||||
|
|
Loading…
Reference in New Issue