1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-07 01:19:57 +00:00

feat: refetch home page when click elk logo (#1129)

This commit is contained in:
Alex Liu 2023-01-31 11:42:46 +08:00 committed by GitHub
parent b62fd01057
commit bd77d467c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 3 deletions

View file

@ -43,8 +43,14 @@ defineSlots<{
}>()
const { t } = useI18n()
const nuxtApp = useNuxtApp()
const { items, prevItems, update, state, endAnchor, error } = usePaginator(paginator, $$(stream), eventType, preprocess)
nuxtApp.hook('elk-logo:click', () => {
update()
nuxtApp.$scrollToTop()
})
</script>
<template>

View file

@ -2,6 +2,13 @@
const { env } = useBuildInfo()
const router = useRouter()
const back = ref<any>('')
const nuxtApp = useNuxtApp()
const onClickLogo = () => {
nuxtApp.hooks.callHook('elk-logo:click')
}
onMounted(() => {
back.value = router.options.history.state.back
})
@ -11,7 +18,6 @@ router.afterEach(() => {
</script>
<template>
<!-- Use external to force refresh page and jump to top of timeline -->
<div flex justify-between>
<NuxtLink
flex items-end gap-4
@ -19,8 +25,8 @@ router.afterEach(() => {
text-2xl
select-none
focus-visible:ring="2 current"
to="/"
external
to="/home"
@click.prevent="onClickLogo"
>
<NavLogo shrink-0 aspect="1/1" sm:h-8 xl:h-10 class="rtl-flip" />
<div hidden xl:block text-secondary>

View file

@ -211,3 +211,9 @@ declare global {
}
}
}
declare module 'nuxt/dist/app' {
interface RuntimeNuxtHooks {
'elk-logo:click': () => void
}
}