From 944e3945058c520f7ec9178b2df882726089ef48 Mon Sep 17 00:00:00 2001 From: Hakadao Date: Mon, 1 Jul 2024 01:35:48 +0800 Subject: [PATCH] fix: cannot load more videos on vertical monitor (#704) close #704 --- src/contentScripts/views/Favorites/Favorites.vue | 5 ++++- src/contentScripts/views/History/History.vue | 6 +++++- .../views/Home/components/Following.vue | 6 +++++- .../views/Home/components/ForYou.vue | 14 ++++---------- .../views/Home/components/SubscribedSeries.vue | 6 +++++- .../views/Home/components/Trending.vue | 6 +++++- src/contentScripts/views/WatchLater/WatchLater.vue | 6 +++++- 7 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/contentScripts/views/Favorites/Favorites.vue b/src/contentScripts/views/Favorites/Favorites.vue index 3b9d109e..1a4a31ab 100644 --- a/src/contentScripts/views/Favorites/Favorites.vue +++ b/src/contentScripts/views/Favorites/Favorites.vue @@ -30,7 +30,7 @@ const activatedCategoryCover = ref('') const shouldMoveCtrlBarUp = ref(false) const currentPageNum = ref(1) const keyword = ref('') -const { handlePageRefresh, handleReachBottom } = useBewlyApp() +const { handlePageRefresh, handleReachBottom, haveScrollbar } = useBewlyApp() const isLoading = ref(true) const isFullPageLoading = ref(false) const noMoreContent = ref() @@ -130,6 +130,9 @@ async function getFavoriteResources( if (!res.data.medias) noMoreContent.value = true + + if (!haveScrollbar()) + await getFavoriteResources(selectedCategory.value!.id, ++currentPageNum.value, keyword) } } finally { diff --git a/src/contentScripts/views/History/History.vue b/src/contentScripts/views/History/History.vue index 2fe43d95..bd78a7e0 100644 --- a/src/contentScripts/views/History/History.vue +++ b/src/contentScripts/views/History/History.vue @@ -21,7 +21,7 @@ const historyList = reactive>([]) const currentPageNum = ref(1) const keyword = ref() const historyStatus = ref() -const { handlePageRefresh, handleReachBottom } = useBewlyApp() +const { handlePageRefresh, handleReachBottom, haveScrollbar } = useBewlyApp() const HistoryBusiness = computed(() => { return Business @@ -79,6 +79,10 @@ function getHistoryList() { } noMoreContent.value = false + + if (!haveScrollbar()) { + getHistoryList() + } } isLoading.value = false }) diff --git a/src/contentScripts/views/Home/components/Following.vue b/src/contentScripts/views/Home/components/Following.vue index 2159f685..88c1a709 100644 --- a/src/contentScripts/views/Home/components/Following.vue +++ b/src/contentScripts/views/Home/components/Following.vue @@ -41,7 +41,7 @@ const containerRef = ref() as Ref const offset = ref('') const updateBaseline = ref('') const noMoreContent = ref(false) -const { handleReachBottom, handlePageRefresh } = useBewlyApp() +const { handleReachBottom, handlePageRefresh, haveScrollbar } = useBewlyApp() onMounted(async () => { initData() @@ -144,6 +144,10 @@ async function getFollowedUsersVideos() { } }) } + + if (!haveScrollbar()) { + getFollowedUsersVideos() + } } else if (response.code === -101) { needToLoginFirst.value = true diff --git a/src/contentScripts/views/Home/components/ForYou.vue b/src/contentScripts/views/Home/components/ForYou.vue index b5e17925..e81c68ac 100644 --- a/src/contentScripts/views/Home/components/ForYou.vue +++ b/src/contentScripts/views/Home/components/ForYou.vue @@ -176,7 +176,6 @@ async function getRecommendVideos() { const pendingVideos: VideoElement[] = Array.from({ length: pageSize }, () => ({ uniqueId: `unique-id-${(videoList.value.length || 0) + i++})}`, } satisfies VideoElement)) - let lastVideoListLength = videoList.value.length videoList.value.push(...pendingVideos) const response: forYouResult = await api.video.getRecommendVideos({ @@ -195,8 +194,6 @@ async function getRecommendVideos() { response.data.item.forEach((item: VideoItem) => { if (!filterFunc.value || filterFunc.value(item)) resData.push(item) - - // resData.push(item) }) // when videoList has length property, it means it is the first time to load @@ -205,10 +202,10 @@ async function getRecommendVideos() { } else { resData.forEach((item) => { - videoList.value[lastVideoListLength++] = { + videoList.value.push({ uniqueId: `${item.id}`, item, - } + }) }) } @@ -231,7 +228,6 @@ async function getAppRecommendVideos() { const pendingVideos: AppVideoElement[] = Array.from({ length: pageSize }, () => ({ uniqueId: `unique-id-${(appVideoList.value.length || 0) + i++})}`, } satisfies AppVideoElement)) - let lastVideoListLength = appVideoList.value.length appVideoList.value.push(...pendingVideos) const response: AppForYouResult = await api.video.getAppRecommendVideos({ @@ -257,10 +253,10 @@ async function getAppRecommendVideos() { } else { resData.forEach((item) => { - appVideoList.value[lastVideoListLength++] = { + appVideoList.value.push({ uniqueId: `${item.idx}`, item, - } + }) }) } @@ -273,8 +269,6 @@ async function getAppRecommendVideos() { } } finally { - // Since the video list in app recommendation mode will filter the ad cards, - // after loading, the video list will be filtered again to remove the empty cards appVideoList.value = appVideoList.value.filter(video => video.item) } } diff --git a/src/contentScripts/views/Home/components/SubscribedSeries.vue b/src/contentScripts/views/Home/components/SubscribedSeries.vue index 268c041c..fa2e0948 100644 --- a/src/contentScripts/views/Home/components/SubscribedSeries.vue +++ b/src/contentScripts/views/Home/components/SubscribedSeries.vue @@ -42,7 +42,7 @@ const offset = ref('') const updateBaseline = ref('') const noMoreContent = ref(false) const noMoreContentWarning = ref(false) -const { handleReachBottom, handlePageRefresh } = useBewlyApp() +const { handleReachBottom, handlePageRefresh, haveScrollbar } = useBewlyApp() onMounted(async () => { initData() @@ -148,6 +148,10 @@ async function getFollowedUsersVideos() { } }) } + + if (!haveScrollbar()) { + getFollowedUsersVideos() + } } else if (response.code === -101) { needToLoginFirst.value = true diff --git a/src/contentScripts/views/Home/components/Trending.vue b/src/contentScripts/views/Home/components/Trending.vue index 1a9300a4..71a87689 100644 --- a/src/contentScripts/views/Home/components/Trending.vue +++ b/src/contentScripts/views/Home/components/Trending.vue @@ -35,7 +35,7 @@ const isLoading = ref(false) const containerRef = ref() as Ref const pn = ref(1) const noMoreContent = ref(false) -const { handleReachBottom, handlePageRefresh } = useBewlyApp() +const { handleReachBottom, handlePageRefresh, haveScrollbar } = useBewlyApp() onMounted(async () => { await initData() @@ -115,6 +115,10 @@ async function getTrendingVideos() { } }) } + + if (!haveScrollbar()) { + getTrendingVideos() + } } } finally { diff --git a/src/contentScripts/views/WatchLater/WatchLater.vue b/src/contentScripts/views/WatchLater/WatchLater.vue index 77441d67..7b236a5d 100644 --- a/src/contentScripts/views/WatchLater/WatchLater.vue +++ b/src/contentScripts/views/WatchLater/WatchLater.vue @@ -18,7 +18,7 @@ const noMoreContent = ref() const allWatchLaterList = ref([]) const currentWatchLaterList = ref([]) const watchLaterCount = ref(0) -const { handlePageRefresh, handleReachBottom } = useBewlyApp() +const { handlePageRefresh, handleReachBottom, haveScrollbar } = useBewlyApp() const pageNum = ref(1) onMounted(() => { @@ -81,6 +81,10 @@ function getCurrentWatchLaterList() { } pageNum.value++ currentWatchLaterList.value.push(...currentList) + + if (!haveScrollbar()) { + getCurrentWatchLaterList() + } } function deleteWatchLaterItem(index: number, aid: number) {