mirror of
https://github.com/BewlyBewly/BewlyBewly.git
synced 2025-04-14 13:15:29 +00:00
fix: avoid using async in onMounted
This commit is contained in:
@@ -28,12 +28,13 @@ nextTick(() => {
|
||||
useEventListener(iframeRef.value?.contentWindow, 'popstate', updateCurrentUrl)
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
onMounted(() => {
|
||||
history.pushState(null, '', props.url)
|
||||
show.value = true
|
||||
headerShow.value = true
|
||||
await nextTick()
|
||||
iframeRef.value?.focus()
|
||||
nextTick(() => {
|
||||
iframeRef.value?.focus()
|
||||
})
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
|
||||
@@ -285,20 +285,21 @@ watch(activatedPage, () => {
|
||||
toggleTopBarVisible(true)
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
onMounted(() => {
|
||||
initData()
|
||||
await nextTick()
|
||||
toggleTopBarVisible(true)
|
||||
nextTick(() => {
|
||||
toggleTopBarVisible(true)
|
||||
|
||||
emitter.off(OVERLAY_SCROLL_BAR_SCROLL)
|
||||
if (isHomePage() && !settings.value.useOriginalBilibiliHomepage) {
|
||||
emitter.on(OVERLAY_SCROLL_BAR_SCROLL, () => {
|
||||
handleScroll()
|
||||
})
|
||||
}
|
||||
else {
|
||||
window.addEventListener('scroll', handleScroll)
|
||||
}
|
||||
emitter.off(OVERLAY_SCROLL_BAR_SCROLL)
|
||||
if (isHomePage() && !settings.value.useOriginalBilibiliHomepage) {
|
||||
emitter.on(OVERLAY_SCROLL_BAR_SCROLL, () => {
|
||||
handleScroll()
|
||||
})
|
||||
}
|
||||
else {
|
||||
window.addEventListener('scroll', handleScroll)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
@@ -519,9 +520,9 @@ defineExpose({
|
||||
<SearchBar
|
||||
v-if="showSearchBar"
|
||||
style="
|
||||
--b-search-bar-normal-color: var(--bew-elevated);
|
||||
--b-search-bar-hover-color: var(--bew-elevated-hover);
|
||||
"
|
||||
--b-search-bar-normal-color: var(--bew-elevated);
|
||||
--b-search-bar-hover-color: var(--bew-elevated-hover);
|
||||
"
|
||||
/>
|
||||
</Transition>
|
||||
</div>
|
||||
|
||||
@@ -277,20 +277,20 @@ watch(activatedPage, () => {
|
||||
toggleTopBarVisible(true)
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
onMounted(() => {
|
||||
initData()
|
||||
await nextTick()
|
||||
toggleTopBarVisible(true)
|
||||
|
||||
emitter.off(OVERLAY_SCROLL_BAR_SCROLL)
|
||||
if (isHomePage() && !settings.value.useOriginalBilibiliHomepage) {
|
||||
emitter.on(OVERLAY_SCROLL_BAR_SCROLL, () => {
|
||||
handleScroll()
|
||||
})
|
||||
}
|
||||
else {
|
||||
window.addEventListener('scroll', handleScroll)
|
||||
}
|
||||
nextTick(() => {
|
||||
toggleTopBarVisible(true)
|
||||
emitter.off(OVERLAY_SCROLL_BAR_SCROLL)
|
||||
if (isHomePage() && !settings.value.useOriginalBilibiliHomepage) {
|
||||
emitter.on(OVERLAY_SCROLL_BAR_SCROLL, () => {
|
||||
handleScroll()
|
||||
})
|
||||
}
|
||||
else {
|
||||
window.addEventListener('scroll', handleScroll)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
|
||||
@@ -44,7 +44,11 @@ watch(activatedMediaId, (newVal: number, oldVal: number) => {
|
||||
getFavoriteResources()
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
onMounted(() => {
|
||||
initData()
|
||||
})
|
||||
|
||||
async function initData() {
|
||||
await getFavoriteCategories()
|
||||
activatedMediaId.value = favoriteCategories[0].id
|
||||
activatedFavoriteTitle.value = favoriteCategories[0].title
|
||||
@@ -67,7 +71,7 @@ onMounted(async () => {
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function getFavoriteCategories() {
|
||||
await api.favorite.getFavoriteCategories({
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
|
||||
@@ -41,7 +41,7 @@ const updateBaseline = ref<string>('')
|
||||
const noMoreContent = ref<boolean>(false)
|
||||
const { handleReachBottom, handlePageRefresh, haveScrollbar } = useBewlyApp()
|
||||
|
||||
onMounted(async () => {
|
||||
onMounted(() => {
|
||||
initData()
|
||||
initPageAction()
|
||||
})
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ const page = ref<number>(1)
|
||||
const noMoreContent = ref<boolean>(false)
|
||||
const { handleReachBottom, handlePageRefresh, haveScrollbar } = useBewlyApp()
|
||||
|
||||
onMounted(async () => {
|
||||
onMounted(() => {
|
||||
initData()
|
||||
initPageAction()
|
||||
})
|
||||
|
||||
@@ -39,7 +39,7 @@ const noMoreContent = ref<boolean>(false)
|
||||
const noMoreContentWarning = ref<boolean>(false)
|
||||
const { handleReachBottom, handlePageRefresh, haveScrollbar } = useBewlyApp()
|
||||
|
||||
onMounted(async () => {
|
||||
onMounted(() => {
|
||||
initData()
|
||||
initPageAction()
|
||||
})
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user