mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-04 17:58:56 +08:00
修复聚合搜索跳转到最后一页后由于列表是空的导致翻页组件隐藏的问题
This commit is contained in:
parent
81167b748c
commit
f02cb72786
@ -34,7 +34,7 @@ export default forwardRef<MusicListType, {}>((props, ref) => {
|
||||
if (isUnmountedRef.current) return
|
||||
requestAnimationFrame(() => {
|
||||
listRef.current?.setList(result.list)
|
||||
listRef.current?.setStatus(boardState.listDetailInfo.maxPage == page ? 'end' : 'idle')
|
||||
listRef.current?.setStatus(boardState.listDetailInfo.maxPage >= page ? 'end' : 'idle')
|
||||
})
|
||||
}).catch(() => {
|
||||
if (boardState.listDetailInfo.list.length && page == 1) clearListDetail()
|
||||
@ -64,7 +64,7 @@ export default forwardRef<MusicListType, {}>((props, ref) => {
|
||||
const result = setListDetail(listDetail, boardState.listDetailInfo.id, page)
|
||||
if (isUnmountedRef.current) return
|
||||
listRef.current?.setList(result.list)
|
||||
listRef.current?.setStatus(boardState.listDetailInfo.maxPage == page ? 'end' : 'idle')
|
||||
listRef.current?.setStatus(boardState.listDetailInfo.maxPage >= page ? 'end' : 'idle')
|
||||
}).catch(() => {
|
||||
if (boardState.listDetailInfo.list.length && page == 1) clearListDetail()
|
||||
listRef.current?.setStatus('error')
|
||||
@ -77,7 +77,7 @@ export default forwardRef<MusicListType, {}>((props, ref) => {
|
||||
const result = setListDetail(listDetail, boardState.listDetailInfo.id, page)
|
||||
if (isUnmountedRef.current) return
|
||||
listRef.current?.setList(result.list)
|
||||
listRef.current?.setStatus(boardState.listDetailInfo.maxPage == page ? 'end' : 'idle')
|
||||
listRef.current?.setStatus(boardState.listDetailInfo.maxPage >= page ? 'end' : 'idle')
|
||||
}).catch(() => {
|
||||
if (boardState.listDetailInfo.list.length && page == 1) clearListDetail()
|
||||
listRef.current?.setStatus('error')
|
||||
|
@ -35,7 +35,7 @@ export default forwardRef<MusicListType, {}>((props, ref) => {
|
||||
if (isUnmountedRef.current) return
|
||||
requestAnimationFrame(() => {
|
||||
listRef.current?.setList(list, source == 'all')
|
||||
listRef.current?.setStatus(searchMusicState.listInfos[searchMusicState.source]!.maxPage == page ? 'end' : 'idle')
|
||||
listRef.current?.setStatus(searchMusicState.listInfos[searchMusicState.source]!.maxPage >= page ? 'end' : 'idle')
|
||||
})
|
||||
}).catch(() => {
|
||||
listRef.current?.setStatus('error')
|
||||
@ -59,7 +59,7 @@ export default forwardRef<MusicListType, {}>((props, ref) => {
|
||||
// const result = setListInfo(listDetail, searchMusicState.listDetailInfo.id, page)
|
||||
if (isUnmountedRef.current) return
|
||||
listRef.current?.setList(list, searchInfoRef.current.source == 'all')
|
||||
listRef.current?.setStatus(searchMusicState.listInfos[searchInfoRef.current.source]!.maxPage == page ? 'end' : 'idle')
|
||||
listRef.current?.setStatus(searchMusicState.listInfos[searchInfoRef.current.source]!.maxPage >= page ? 'end' : 'idle')
|
||||
}).catch(() => {
|
||||
listRef.current?.setStatus('error')
|
||||
})
|
||||
@ -72,7 +72,7 @@ export default forwardRef<MusicListType, {}>((props, ref) => {
|
||||
// const result = setListInfo(listDetail, searchMusicState.listDetailInfo.id, page)
|
||||
if (isUnmountedRef.current) return
|
||||
listRef.current?.setList(list, searchInfoRef.current.source == 'all')
|
||||
listRef.current?.setStatus(info.maxPage == page ? 'end' : 'idle')
|
||||
listRef.current?.setStatus(info.maxPage >= page ? 'end' : 'idle')
|
||||
}).catch(() => {
|
||||
listRef.current?.setStatus('error')
|
||||
})
|
||||
|
@ -29,7 +29,7 @@ export default forwardRef<ListType, {}>((props, ref) => {
|
||||
if (isUnmountedRef.current) return
|
||||
requestAnimationFrame(() => {
|
||||
listRef.current?.setList(result.list)
|
||||
listRef.current?.setStatus(songlistState.listInfo.maxPage == page ? 'end' : 'idle')
|
||||
listRef.current?.setStatus(songlistState.listInfo.maxPage >= page ? 'end' : 'idle')
|
||||
})
|
||||
}).catch(() => {
|
||||
if (songlistState.listInfo.list.length && page == 1) clearList()
|
||||
@ -54,7 +54,7 @@ export default forwardRef<ListType, {}>((props, ref) => {
|
||||
const result = setList(info, songlistState.listInfo.tagId, songlistState.listInfo.sortId, page)
|
||||
if (isUnmountedRef.current) return
|
||||
listRef.current?.setList(result.list)
|
||||
listRef.current?.setStatus(songlistState.listInfo.maxPage == page ? 'end' : 'idle')
|
||||
listRef.current?.setStatus(songlistState.listInfo.maxPage >= page ? 'end' : 'idle')
|
||||
}).catch(() => {
|
||||
if (songlistState.listInfo.list.length && page == 1) clearList()
|
||||
listRef.current?.setStatus('error')
|
||||
@ -67,7 +67,7 @@ export default forwardRef<ListType, {}>((props, ref) => {
|
||||
const result = setList(info, songlistState.listInfo.tagId, songlistState.listInfo.sortId, page)
|
||||
if (isUnmountedRef.current) return
|
||||
listRef.current?.setList(result.list)
|
||||
listRef.current?.setStatus(songlistState.listInfo.maxPage == page ? 'end' : 'idle')
|
||||
listRef.current?.setStatus(songlistState.listInfo.maxPage >= page ? 'end' : 'idle')
|
||||
}).catch(() => {
|
||||
if (songlistState.listInfo.list.length && page == 1) clearList()
|
||||
listRef.current?.setStatus('error')
|
||||
|
@ -52,7 +52,7 @@ export default forwardRef<MusicListType, MusicListProps>(({ componentId }, ref)
|
||||
imgUrl: songlistState.selectListInfo.img ?? listDetailInfo.info.img,
|
||||
})
|
||||
listRef.current?.setList(result.list)
|
||||
listRef.current?.setStatus(songlistState.listDetailInfo.maxPage == page ? 'end' : 'idle')
|
||||
listRef.current?.setStatus(songlistState.listDetailInfo.maxPage >= page ? 'end' : 'idle')
|
||||
})
|
||||
}).catch(() => {
|
||||
if (songlistState.listDetailInfo.list.length && page == 1) clearListDetail()
|
||||
@ -82,7 +82,7 @@ export default forwardRef<MusicListType, MusicListProps>(({ componentId }, ref)
|
||||
const result = setListDetail(listDetail, songlistState.listDetailInfo.id, page)
|
||||
if (isUnmountedRef.current) return
|
||||
listRef.current?.setList(result.list)
|
||||
listRef.current?.setStatus(songlistState.listDetailInfo.maxPage == page ? 'end' : 'idle')
|
||||
listRef.current?.setStatus(songlistState.listDetailInfo.maxPage >= page ? 'end' : 'idle')
|
||||
}).catch(() => {
|
||||
if (songlistState.listDetailInfo.list.length && page == 1) clearListDetail()
|
||||
listRef.current?.setStatus('error')
|
||||
@ -95,7 +95,7 @@ export default forwardRef<MusicListType, MusicListProps>(({ componentId }, ref)
|
||||
const result = setListDetail(listDetail, songlistState.listDetailInfo.id, page)
|
||||
if (isUnmountedRef.current) return
|
||||
listRef.current?.setList(result.list)
|
||||
listRef.current?.setStatus(songlistState.listDetailInfo.maxPage == page ? 'end' : 'idle')
|
||||
listRef.current?.setStatus(songlistState.listDetailInfo.maxPage >= page ? 'end' : 'idle')
|
||||
}).catch(() => {
|
||||
if (songlistState.listDetailInfo.list.length && page == 1) clearListDetail()
|
||||
listRef.current?.setStatus('error')
|
||||
|
@ -12,7 +12,8 @@ export default {
|
||||
state.listDetailInfo.list = page == 1 ? [...result.list] : [...state.listDetailInfo.list, ...result.list]
|
||||
state.listDetailInfo.id = id
|
||||
state.listDetailInfo.source = result.source
|
||||
state.listDetailInfo.total = result.total
|
||||
if (page == 1 || (result.total && result.list.length)) state.listDetailInfo.total = result.total
|
||||
else state.listDetailInfo.total = result.limit * page
|
||||
state.listDetailInfo.limit = result.limit
|
||||
state.listDetailInfo.page = page
|
||||
state.listDetailInfo.maxPage = Math.ceil(result.total / result.limit)
|
||||
|
@ -48,6 +48,7 @@ export default {
|
||||
},
|
||||
addHistoryWord(word: string) {
|
||||
let index = state.historyList.indexOf(word)
|
||||
if (index == 0) return
|
||||
if (index > -1) state.historyList.splice(index, 1)
|
||||
if (state.historyList.length >= 15) state.historyList.splice(14, state.historyList.length - 14)
|
||||
state.historyList.unshift(word)
|
||||
|
@ -32,21 +32,23 @@ const handleSortList = (list: LX.Music.MusicInfoOnline[], keyword: string) => {
|
||||
|
||||
const setLists = (results: SearchResult[], page: number, text: string): LX.Music.MusicInfoOnline[] => {
|
||||
let pages = []
|
||||
let total = 0
|
||||
// let limit = 0
|
||||
let totals = []
|
||||
let limit = 0
|
||||
let list = [] as LX.Music.MusicInfoOnline[]
|
||||
for (const source of results) {
|
||||
state.maxPages[source.source] = source.allPage
|
||||
limit = Math.max(source.limit, limit)
|
||||
if (source.allPage < page) continue
|
||||
arrPush(list, source.list)
|
||||
pages.push(source.allPage)
|
||||
total += source.total
|
||||
// limit = Math.max(source.limit, limit)
|
||||
totals.push(source.total)
|
||||
}
|
||||
list = handleSortList(list.map(s => toNewMusicInfo(s) as LX.Music.MusicInfoOnline), text)
|
||||
let listInfo = state.listInfos.all
|
||||
listInfo.maxPage = Math.max(...pages)
|
||||
listInfo.total = total
|
||||
listInfo.maxPage = Math.max(0, ...pages)
|
||||
const total = Math.max(0, ...totals)
|
||||
if (page == 1 || (total && list.length)) listInfo.total = total
|
||||
else listInfo.total = limit * page
|
||||
// listInfo.limit = limit
|
||||
listInfo.page = page
|
||||
listInfo.list = deduplicationList(page > 1 ? [...listInfo.list, ...list] : list)
|
||||
@ -60,7 +62,8 @@ const setList = (datas: SearchResult, page: number, text: string): LX.Music.Musi
|
||||
let listInfo = state.listInfos[datas.source] as ListInfo
|
||||
const list = datas.list.map(s => toNewMusicInfo(s) as LX.Music.MusicInfoOnline)
|
||||
listInfo.list = deduplicationList(page == 1 ? list : [...listInfo.list, ...list])
|
||||
listInfo.total = datas.total
|
||||
if (page == 1 || (datas.total && datas.list.length)) listInfo.total = datas.total
|
||||
else listInfo.total = datas.limit * page
|
||||
listInfo.maxPage = datas.allPage
|
||||
listInfo.page = page
|
||||
listInfo.limit = datas.limit
|
||||
|
@ -34,18 +34,20 @@ let maxTotals: Partial<Record<LX.OnlineSource, number>> = {
|
||||
}
|
||||
const setLists = (results: SearchResult[], page: number, text: string): ListInfoItem[] => {
|
||||
let totals = []
|
||||
// let limit = 0
|
||||
let limit = 0
|
||||
let list = []
|
||||
for (const source of results) {
|
||||
list.push(...source.list)
|
||||
totals.push(source.total)
|
||||
maxTotals[source.source] = source.total
|
||||
state.maxPages[source.source] = Math.ceil(source.total / source.limit)
|
||||
// limit = Math.max(source.limit, limit)
|
||||
limit = Math.max(source.limit, limit)
|
||||
}
|
||||
|
||||
let listInfo = state.listInfos.all
|
||||
listInfo.total = Math.max(...totals)
|
||||
const total = Math.max(0, ...totals)
|
||||
if (page == 1 || (total && list.length)) listInfo.total = total
|
||||
else listInfo.total = limit * page
|
||||
listInfo.page = page
|
||||
list = handleSortList(list, text)
|
||||
listInfo.list = page > 1 ? [...listInfo.list, ...list] : list
|
||||
@ -57,7 +59,8 @@ const setList = (datas: SearchResult, page: number, text: string): ListInfoItem[
|
||||
// console.log(datas.source, datas.list)
|
||||
let listInfo = state.listInfos[datas.source] as SearchListInfo
|
||||
listInfo.list = page == 1 ? datas.list : [...listInfo.list, ...datas.list]
|
||||
listInfo.total = datas.total
|
||||
if (page == 1 || (datas.total && datas.list.length)) listInfo.total = datas.total
|
||||
else listInfo.total = datas.limit * page
|
||||
listInfo.page = page
|
||||
listInfo.limit = datas.limit
|
||||
state.source = datas.source
|
||||
|
@ -12,7 +12,8 @@ export default {
|
||||
},
|
||||
setList(result: ListInfo, tagId: string, sortId: string, page: number) {
|
||||
state.listInfo.list = page == 1 ? [...result.list] : [...state.listInfo.list, ...result.list]
|
||||
state.listInfo.total = result.total
|
||||
if (page == 1 || (result.total && result.list.length)) state.listInfo.total = result.total
|
||||
else state.listInfo.total = result.limit * page
|
||||
state.listInfo.limit = result.limit
|
||||
state.listInfo.page = page
|
||||
state.listInfo.source = result.source
|
||||
@ -37,7 +38,8 @@ export default {
|
||||
state.listDetailInfo.list = page == 1 ? [...result.list] : [...state.listDetailInfo.list, ...result.list]
|
||||
state.listDetailInfo.id = id
|
||||
state.listDetailInfo.source = result.source
|
||||
state.listDetailInfo.total = result.total
|
||||
if (page == 1 || (result.total && result.list.length)) state.listDetailInfo.total = result.total
|
||||
else state.listDetailInfo.total = result.limit * page
|
||||
state.listDetailInfo.limit = result.limit
|
||||
state.listDetailInfo.page = page
|
||||
state.listDetailInfo.info = { ...result.info }
|
||||
|
Loading…
x
Reference in New Issue
Block a user