fix: resolve always loading issue

This commit is contained in:
Hakadao
2024-07-01 02:23:24 +08:00
parent e03effbd4a
commit 3b670635a1
6 changed files with 12 additions and 7 deletions

View File

@@ -31,7 +31,7 @@ const shouldMoveCtrlBarUp = ref<boolean>(false)
const currentPageNum = ref<number>(1)
const keyword = ref<string>('')
const { handlePageRefresh, handleReachBottom, haveScrollbar } = useBewlyApp()
const isLoading = ref<boolean>(true)
const isLoading = ref<boolean>(false)
const isFullPageLoading = ref<boolean>(false)
const noMoreContent = ref<boolean>()
@@ -112,6 +112,8 @@ async function getFavoriteResources(
pn: number,
keyword = '' as string,
) {
// if (pn === 1)
// isFullPageLoading.value = true
isLoading.value = true
try {
const res: FavoritesResult = await api.favorite.getFavoriteResources({
@@ -129,16 +131,19 @@ async function getFavoriteResources(
if (!res.data.medias)
noMoreContent.value = true
if (!haveScrollbar())
if (!haveScrollbar() && !noMoreContent.value)
await getFavoriteResources(selectedCategory.value!.id, ++currentPageNum.value, keyword)
}
}
finally {
isLoading.value = false
// isFullPageLoading.value = false
}
}
async function changeCategory(categoryItem: FavoriteCategory) {
if (isLoading.value)
return
currentPageNum.value = 1
selectedCategory.value = categoryItem
favoriteResources.length = 0

View File

@@ -80,7 +80,7 @@ function getHistoryList() {
noMoreContent.value = false
if (!haveScrollbar()) {
if (!haveScrollbar() && !noMoreContent.value) {
getHistoryList()
}
}

View File

@@ -145,7 +145,7 @@ async function getFollowedUsersVideos() {
})
}
if (!haveScrollbar()) {
if (!haveScrollbar() && !noMoreContent.value) {
getFollowedUsersVideos()
}
}

View File

@@ -149,7 +149,7 @@ async function getFollowedUsersVideos() {
})
}
if (!haveScrollbar()) {
if (!haveScrollbar() && !noMoreContent.value) {
getFollowedUsersVideos()
}
}

View File

@@ -116,7 +116,7 @@ async function getTrendingVideos() {
})
}
if (!haveScrollbar()) {
if (!haveScrollbar() && !noMoreContent.value) {
getTrendingVideos()
}
}

View File

@@ -82,7 +82,7 @@ function getCurrentWatchLaterList() {
pageNum.value++
currentWatchLaterList.value.push(...currentList)
if (!haveScrollbar()) {
if (!haveScrollbar() && !noMoreContent.value) {
getCurrentWatchLaterList()
}
}