mirror of
https://github.com/BewlyBewly/BewlyBewly.git
synced 2025-04-14 13:15:29 +00:00
fix(top-bar): top bar cannot auto-hide on the home page
This commit is contained in:
@@ -5,7 +5,7 @@ import type { Ref, UnwrapNestedRefs } from 'vue'
|
||||
import { useApiClient } from '~/composables/api'
|
||||
import { useBewlyApp } from '~/composables/useAppProvider'
|
||||
import { useDelayedHover } from '~/composables/useDelayedHover'
|
||||
import { TOP_BAR_VISIBILITY_CHANGE } from '~/constants/globalEvents'
|
||||
import { OVERLAY_SCROLL_BAR_SCROLL, TOP_BAR_VISIBILITY_CHANGE } from '~/constants/globalEvents'
|
||||
import { AppPage } from '~/enums/appEnums'
|
||||
import { settings } from '~/logic'
|
||||
import { getUserID, isHomePage } from '~/utils/main'
|
||||
@@ -292,11 +292,21 @@ onMounted(async () => {
|
||||
initData()
|
||||
await nextTick()
|
||||
toggleTopBarVisible(true)
|
||||
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)
|
||||
}
|
||||
})
|
||||
|
||||
onBeforeMount(() => {
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('scroll', handleScroll)
|
||||
emitter.off(OVERLAY_SCROLL_BAR_SCROLL)
|
||||
})
|
||||
|
||||
async function initData() {
|
||||
@@ -310,7 +320,7 @@ async function initData() {
|
||||
}
|
||||
|
||||
function handleScroll() {
|
||||
if (isHomePage()) {
|
||||
if (isHomePage() && !settings.value.useOriginalBilibiliHomepage) {
|
||||
const osInstance = scrollbarRef.value?.osInstance()
|
||||
scrollTop.value = osInstance.elements().viewport.scrollTop as number
|
||||
}
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export const TOP_BAR_VISIBILITY_CHANGE = 'topBarVisibilityChange'
|
||||
export const OVERLAY_SCROLL_BAR_SCROLL = 'overlayScrollBarScroll'
|
||||
|
||||
@@ -13,9 +13,11 @@ import Settings from '~/components/Settings/Settings.vue'
|
||||
import TopBar from '~/components/TopBar/TopBar.vue'
|
||||
import type { BewlyAppProvider } from '~/composables/useAppProvider'
|
||||
import { useDark } from '~/composables/useDark'
|
||||
import { OVERLAY_SCROLL_BAR_SCROLL } from '~/constants/globalEvents'
|
||||
import { AppPage, LanguageType } from '~/enums/appEnums'
|
||||
import { accessKey, settings } from '~/logic'
|
||||
import { getUserID, hexToRGBA, isHomePage, scrollToTop } from '~/utils/main'
|
||||
import emitter from '~/utils/mitt'
|
||||
|
||||
const { isDark } = useDark()
|
||||
const activatedPage = ref<AppPage>(settings.value.dockItemVisibilityList.find(e => e.visible === true)?.page ?? AppPage.Home)
|
||||
@@ -177,6 +179,8 @@ function handleAdaptToOtherPageStylesChange() {
|
||||
}
|
||||
|
||||
function handleOsScroll() {
|
||||
emitter.emit(OVERLAY_SCROLL_BAR_SCROLL)
|
||||
|
||||
const osInstance = scrollbarRef.value?.osInstance()
|
||||
const { viewport } = osInstance.elements()
|
||||
const { scrollTop, scrollHeight, clientHeight } = viewport // get scroll offset
|
||||
|
||||
Reference in New Issue
Block a user