修复在线音乐列表获取失败时无限循环请求的问题
This commit is contained in:
@@ -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
|
||||
return this.musicSearch(str, page).then(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)
|
||||
|
||||
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.page = page
|
||||
|
||||
Reference in New Issue
Block a user