fix: page refresh reset action

This commit is contained in:
starknt
2024-01-11 17:29:21 +08:00
parent 0d1735ab87
commit f654385f75
4 changed files with 27 additions and 11 deletions

View File

@@ -40,6 +40,8 @@ function initPageAction() {
recommendAnimeList.length = 0
popularAnimeList.length = 0
cursor.value = 0
noMoreContent.value = false
noMoreContentWarning.value = false
getAnimeWatchList()
getPopularAnimeList()
getRecommendAnimeList()

View File

@@ -42,6 +42,8 @@ function initPageAction() {
return
favoriteResources.length = 0
currentPageNum.value = 1
noMoreContent.value = false
noMoreContentWarning.value = false
handleSearch()
}
}

View File

@@ -42,6 +42,8 @@ function initPageAction() {
handlePageRefresh.value = () => {
historyList.length = 0
currentPageNum.value = 1
noMoreContent.value = false
noMoreContentWarning.value = false
getHistoryList()
}
}

View File

@@ -13,24 +13,34 @@ const needToLoginFirst = ref<boolean>(false)
const containerRef = ref<HTMLElement>() as Ref<HTMLElement>
const refreshIdx = ref<number>(1)
const noMoreContent = ref<boolean>(false)
const noMoreContentWarning = ref<boolean>(false)
const { handleReachBottom, handlePageRefresh } = useBewlyApp()
function initPageAction() {
handleReachBottom.value = async () => {
if (!isLoading.value) {
if (settings.value.recommendationMode === 'web') {
getRecommendVideos()
}
else {
for (let i = 0; i < 3; i++)
await getAppRecommendVideos()
}
if (isLoading.value)
return
if (noMoreContent.value) {
noMoreContentWarning.value = true
return
}
if (settings.value.recommendationMode === 'web') {
getRecommendVideos()
}
else {
for (let i = 0; i < 3; i++)
await getAppRecommendVideos()
}
}
handlePageRefresh.value = async () => {
if (isLoading.value)
return
videoList.length = 0
appVideoList.length = 0
noMoreContent.value = false
noMoreContentWarning.value = false
if (settings.value.recommendationMode === 'web') {
await getRecommendVideos()
}
@@ -75,9 +85,6 @@ onActivated(() => {
})
async function getRecommendVideos() {
if (noMoreContent.value)
return
isLoading.value = true
try {
const response: forYouResult = await browser.runtime.sendMessage({
@@ -217,6 +224,9 @@ function jumpToLoginPage() {
</template>
</div>
<!-- no more content -->
<Empty v-if="noMoreContentWarning" class="py-4" :description="$t('common.no_more_content')" />
<Transition name="fade">
<Loading v-if="isLoading" />
</Transition>