mirror of
https://github.com/BewlyBewly/BewlyBewly.git
synced 2025-04-14 13:15:29 +00:00
feat: scroll to top when homepage tab is changed
This commit is contained in:
@@ -19,6 +19,8 @@ import { AppPage, LanguageType } from '~/enums/appEnums'
|
||||
import { getUserID, hexToRGBA, smoothScrollToTop } from '~/utils/main'
|
||||
import emitter from '~/utils/mitt'
|
||||
|
||||
provide('handleBackToTop', handleBackToTop)
|
||||
|
||||
const activatedPage = ref<AppPage>(settings.value.startupPage ?? AppPage.Home)
|
||||
const { locale } = useI18n()
|
||||
const [showSettings, toggleSettings] = useToggle(false)
|
||||
|
||||
@@ -4,6 +4,8 @@ import Following from './components/Following.vue'
|
||||
import emitter from '~/utils/mitt'
|
||||
import { settings } from '~/logic'
|
||||
|
||||
const handleBackToTop = inject('handleBackToTop') as () => void
|
||||
|
||||
const recommendContentKey = ref<string>(`recommendContent${Number(new Date())}`)
|
||||
const activatedPage = ref<'RecommendContent' | 'Following'>('RecommendContent')
|
||||
const pages = { RecommendContent, Following }
|
||||
@@ -19,6 +21,10 @@ const tabs = reactive<{ label: string; value: 'RecommendContent' | 'Following' }
|
||||
},
|
||||
])
|
||||
|
||||
watch(() => activatedPage.value, () => {
|
||||
handleBackToTop()
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
emitter.off('pageRefresh')
|
||||
emitter.on('pageRefresh', async () => {
|
||||
|
||||
Reference in New Issue
Block a user