修复自动换源导致的搜索列表每页变成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,13 +11,13 @@ export default {
total: 0,
page: 0,
allPage: 1,
musicSearch(str, page) {
musicSearch(str, page, limit) {
if (searchRequest && searchRequest.cancelHttp) searchRequest.cancelHttp()
searchRequest = xmRequest('/api/search/searchSongs', {
key: str,
pagingVO: {
page: page,
pageSize: this.limit,
pageSize: limit,
},
})
return searchRequest.promise.then(({ body }) => body)
@@ -89,9 +89,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) return this.search(str, page, { limit }, retryNum)
if (result.code !== 'SUCCESS') return this.search(str, page, { limit }, retryNum)
// const songResultData = result.data || { songs: [], total: 0 }
@@ -101,12 +101,12 @@ export default {
this.total = parseInt(result.result.data.pagingVO.count)
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: 'xm',
})