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:
parent
b62fd01057
commit
bd77d467c3
3 changed files with 21 additions and 3 deletions
|
@ -43,8 +43,14 @@ defineSlots<{
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
const nuxtApp = useNuxtApp()
|
||||||
|
|
||||||
const { items, prevItems, update, state, endAnchor, error } = usePaginator(paginator, $$(stream), eventType, preprocess)
|
const { items, prevItems, update, state, endAnchor, error } = usePaginator(paginator, $$(stream), eventType, preprocess)
|
||||||
|
|
||||||
|
nuxtApp.hook('elk-logo:click', () => {
|
||||||
|
update()
|
||||||
|
nuxtApp.$scrollToTop()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -2,6 +2,13 @@
|
||||||
const { env } = useBuildInfo()
|
const { env } = useBuildInfo()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const back = ref<any>('')
|
const back = ref<any>('')
|
||||||
|
|
||||||
|
const nuxtApp = useNuxtApp()
|
||||||
|
|
||||||
|
const onClickLogo = () => {
|
||||||
|
nuxtApp.hooks.callHook('elk-logo:click')
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
back.value = router.options.history.state.back
|
back.value = router.options.history.state.back
|
||||||
})
|
})
|
||||||
|
@ -11,7 +18,6 @@ router.afterEach(() => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<!-- Use external to force refresh page and jump to top of timeline -->
|
|
||||||
<div flex justify-between>
|
<div flex justify-between>
|
||||||
<NuxtLink
|
<NuxtLink
|
||||||
flex items-end gap-4
|
flex items-end gap-4
|
||||||
|
@ -19,8 +25,8 @@ router.afterEach(() => {
|
||||||
text-2xl
|
text-2xl
|
||||||
select-none
|
select-none
|
||||||
focus-visible:ring="2 current"
|
focus-visible:ring="2 current"
|
||||||
to="/"
|
to="/home"
|
||||||
external
|
@click.prevent="onClickLogo"
|
||||||
>
|
>
|
||||||
<NavLogo shrink-0 aspect="1/1" sm:h-8 xl:h-10 class="rtl-flip" />
|
<NavLogo shrink-0 aspect="1/1" sm:h-8 xl:h-10 class="rtl-flip" />
|
||||||
<div hidden xl:block text-secondary>
|
<div hidden xl:block text-secondary>
|
||||||
|
|
|
@ -211,3 +211,9 @@ declare global {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare module 'nuxt/dist/app' {
|
||||||
|
interface RuntimeNuxtHooks {
|
||||||
|
'elk-logo:click': () => void
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue