fix: avoid using async in onMounted

This commit is contained in:
Hakadao
2024-12-15 22:51:12 +08:00
parent 47644b530e
commit fc902f7e74
10 changed files with 55 additions and 46 deletions

View File

@@ -28,12 +28,7 @@ const isLoading = ref<boolean>(false)
const isFullPageLoading = ref<boolean>(false)
const noMoreContent = ref<boolean>(false)
onMounted(async () => {
await getFavoriteCategories()
changeCategory(favoriteCategories[0])
initPageAction()
onMounted(() => {
emitter.off(TOP_BAR_VISIBILITY_CHANGE)
emitter.on(TOP_BAR_VISIBILITY_CHANGE, (val) => {
shouldMoveCtrlBarUp.value = false
@@ -49,8 +44,16 @@ onMounted(async () => {
shouldMoveCtrlBarUp.value = true
}
})
initPageAction()
initData()
})
async function initData() {
await getFavoriteCategories()
changeCategory(favoriteCategories[0])
}
onUnmounted(() => {
emitter.off(TOP_BAR_VISIBILITY_CHANGE)
})

View File

@@ -41,7 +41,7 @@ const updateBaseline = ref<string>('')
const noMoreContent = ref<boolean>(false)
const { handleReachBottom, handlePageRefresh, haveScrollbar } = useBewlyApp()
onMounted(async () => {
onMounted(() => {
initData()
initPageAction()
})

View File

@@ -97,11 +97,11 @@ watch(() => settings.value.recommendationMode, () => {
initData()
})
onMounted(async () => {
onMounted(() => {
// Delay by 0.2 seconds to obtain the `settings.value.recommendationMode` value
// otherwise the `settings.value.recommendationMode` value will be undefined
// i have no idea to fix that...
setTimeout(async () => {
setTimeout(() => {
initData()
}, 200)

View File

@@ -37,7 +37,7 @@ const page = ref<number>(1)
const noMoreContent = ref<boolean>(false)
const { handleReachBottom, handlePageRefresh, haveScrollbar } = useBewlyApp()
onMounted(async () => {
onMounted(() => {
initData()
initPageAction()
})

View File

@@ -39,7 +39,7 @@ const noMoreContent = ref<boolean>(false)
const noMoreContentWarning = ref<boolean>(false)
const { handleReachBottom, handlePageRefresh, haveScrollbar } = useBewlyApp()
onMounted(async () => {
onMounted(() => {
initData()
initPageAction()
})

View File

@@ -35,8 +35,8 @@ const pn = ref<number>(1)
const noMoreContent = ref<boolean>(false)
const { handleReachBottom, handlePageRefresh, haveScrollbar } = useBewlyApp()
onMounted(async () => {
await initData()
onMounted(() => {
initData()
initPageAction()
})