fix: make haveScrollbar() async in multiple components
Some checks are pending
CI / Test (lts/*, ubuntu-latest) (push) Waiting to run
CI / Test (lts/*, windows-latest) (push) Waiting to run
CI / Test (lts/-1, ubuntu-latest) (push) Waiting to run
CI / Test (lts/-1, windows-latest) (push) Waiting to run

This change updates several components to use an async version of `haveScrollbar()`, ensuring proper handling of scrollbar detection across different views like Favorites, History, Home components, and WatchLater.
This commit is contained in:
Hakadao
2025-02-11 18:05:31 +08:00
parent d7a242416b
commit f9857a23bb
9 changed files with 13 additions and 14 deletions

View File

@@ -180,10 +180,9 @@ function handleDockItemClick(dockItem: DockItem) {
}
else {
if (isHomePage()) {
// Replace NextTick with setTimeout(200), otherwise osInstance in function 'changeActivatePage' will be undefined
setTimeout(() => {
nextTick(() => {
changeActivatePage(dockItem.page)
}, 200)
})
}
else {
location.href = `https://www.bilibili.com/?page=${dockItem.page}`

View File

@@ -127,7 +127,7 @@ async function getFavoriteResources(
if (!res.data.medias)
noMoreContent.value = true
if (!haveScrollbar() && !noMoreContent.value)
if (!await haveScrollbar() && !noMoreContent.value)
await getFavoriteResources(selectedCategory.value!.id, ++currentPageNum.value, keyword)
}
}

View File

@@ -64,7 +64,7 @@ function getHistoryList() {
? historyList[historyList.length - 1].view_at
: 0,
})
.then((res: HistoryResult) => {
.then(async (res: HistoryResult) => {
if (res.code === 0) {
if (Array.isArray(res.data.list) && res.data.list.length > 0)
historyList.push(...res.data.list)
@@ -77,7 +77,7 @@ function getHistoryList() {
noMoreContent.value = false
if (!haveScrollbar() && !noMoreContent.value) {
if (!await haveScrollbar() && !noMoreContent.value) {
getHistoryList()
}
}

View File

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

View File

@@ -227,7 +227,7 @@ async function getRecommendVideos() {
if (!needToLoginFirst.value) {
await nextTick()
if (!haveScrollbar() || filledItems.length < PAGE_SIZE || filledItems.length < 1) {
if (!await haveScrollbar() || filledItems.length < PAGE_SIZE || filledItems.length < 1) {
getRecommendVideos()
}
}
@@ -306,7 +306,7 @@ async function getAppRecommendVideos() {
if (!needToLoginFirst.value) {
await nextTick()
if (!haveScrollbar() || filledItems.length < PAGE_SIZE || filledItems.length < 1) {
if (!await haveScrollbar() || filledItems.length < PAGE_SIZE || filledItems.length < 1) {
getAppRecommendVideos()
}
}

View File

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

View File

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

View File

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

View File

@@ -70,7 +70,7 @@ async function getAllWatchLaterList() {
}
}
function getCurrentWatchLaterList() {
async function getCurrentWatchLaterList() {
const allWatchLaterListCopy = JSON.parse(JSON.stringify(allWatchLaterList.value))
const currentList = allWatchLaterListCopy.slice((pageNum.value - 1) * 10, pageNum.value * 10)
@@ -81,7 +81,7 @@ function getCurrentWatchLaterList() {
pageNum.value++
currentWatchLaterList.value.push(...currentList)
if (!haveScrollbar() && !noMoreContent.value) {
if (!await haveScrollbar() && !noMoreContent.value) {
getCurrentWatchLaterList()
}
}