修复自动换源导致的搜索列表每页变成10条数据的问题

This commit is contained in:
lyswhut
2021-01-12 11:42:56 +08:00
parent a5fce15661
commit 2fd7e4503a
8 changed files with 46 additions and 45 deletions
+6 -6
View File
@@ -11,9 +11,9 @@ export default {
total: 0,
page: 0,
allPage: 1,
musicSearch(str, page) {
musicSearch(str, page, limit) {
if (searchRequest && searchRequest.cancelHttp) searchRequest.cancelHttp()
searchRequest = httpFetch(`http://ioscdn.kugou.com/api/v3/search/song?keyword=${encodeURIComponent(str)}&page=${page}&pagesize=${this.limit}&showtype=10&plat=2&version=7910&tag=1&correct=1&privilege=1&sver=5`)
searchRequest = httpFetch(`http://ioscdn.kugou.com/api/v3/search/song?keyword=${encodeURIComponent(str)}&page=${page}&pagesize=${limit}&showtype=10&plat=2&version=7910&tag=1&correct=1&privilege=1&sver=5`)
return searchRequest.promise.then(({ body }) => body)
},
handleResult(rawData) {
@@ -71,9 +71,9 @@ export default {
},
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) limit = this.limit
// http://newlyric.kuwo.cn/newlyric.lrc?62355680
return this.musicSearch(str, page).then(result => {
return this.musicSearch(str, page, limit).then(result => {
if (!result || result.errcode !== 0) return this.search(str, page, { limit }, retryNum)
let list = this.handleResult(result.data.info)
@@ -81,12 +81,12 @@ export default {
this.total = result.data.total
this.page = page
this.allPage = Math.ceil(this.total / this.limit)
this.allPage = Math.ceil(this.total / limit)
return Promise.resolve({
list,
allPage: this.allPage,
limit: this.limit,
limit,
total: this.total,
source: 'kg',
})