From 1f82f6834105fa9292aab186d772c5105d7ef8a7 Mon Sep 17 00:00:00 2001 From: Hakadao Date: Wed, 19 Feb 2025 11:00:24 +0800 Subject: [PATCH] fix(following): improve livestreaming video loading logic --- .../views/Home/components/Following.vue | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/contentScripts/views/Home/components/Following.vue b/src/contentScripts/views/Home/components/Following.vue index c7d43223..594fce2d 100644 --- a/src/contentScripts/views/Home/components/Following.vue +++ b/src/contentScripts/views/Home/components/Following.vue @@ -40,6 +40,10 @@ const gridClass = computed((): string => { }) const videoList = ref([]) +/** + * Get all livestreaming videos of followed users + */ +const livePage = ref(1) const liveVideoList = ref([]) const isLoading = ref(false) const needToLoginFirst = ref(false) @@ -50,7 +54,6 @@ const noMoreContent = ref(false) const { handleReachBottom, handlePageRefresh, haveScrollbar } = useBewlyApp() onMounted(() => { - getLiveVideoList() initData() initPageAction() }) @@ -79,9 +82,13 @@ function initPageAction() { async function initData() { offset.value = '' updateBaseline.value = '' + liveVideoList.value.length = 0 + livePage.value = 1 videoList.value.length = 0 noMoreContent.value = false + if (settings.value.followingTabShowLivestreamingVideos) + getLiveVideoList() await getData() } @@ -99,10 +106,6 @@ async function getData() { } } -/** - * Get all livestreaming videos of followed users - */ -const livePage = ref(1) async function getLiveVideoList() { let lastLiveVideoListLength = liveVideoList.value.length try { @@ -148,7 +151,7 @@ async function getLiveVideoList() { finally { // 當直播列表結果大於9時(9是返回的列表數量)且如果最后一支影片還是正在直播,則繼續獲取 if (liveVideoList.value.length > 9 && liveVideoList.value[liveVideoList.value.length - 1]?.item?.live_status === 1) { - getFollowedUsersVideos() + getLiveVideoList() } } }