Merge pull request #536 from nagisa77/codex/add-logo-click-to-refresh-homepage

feat: refresh home when clicking header logo
This commit is contained in:
Tim
2025-08-14 11:00:37 +08:00
committed by GitHub
2 changed files with 18 additions and 2 deletions

View File

@@ -75,7 +75,11 @@ const userMenu = ref(null)
const menuBtn = ref(null)
const goToHome = async () => {
await navigateTo('/', { replace: true })
if (router.currentRoute.value.fullPath === '/') {
window.dispatchEvent(new Event('refresh-home'))
} else {
await navigateTo('/', { replace: true })
}
}
const search = () => {
showSearch.value = true

View File

@@ -112,7 +112,7 @@
</template>
<script setup>
import { ref, watch } from 'vue'
import { ref, watch, onMounted, onBeforeUnmount } from 'vue'
import ArticleCategory from '~/components/ArticleCategory.vue'
import ArticleTags from '~/components/ArticleTags.vue'
import CategorySelect from '~/components/CategorySelect.vue'
@@ -397,6 +397,18 @@ const fetchContent = async (reset = false) => {
}
}
const refreshHome = () => {
fetchContent(true)
}
onMounted(() => {
window.addEventListener('refresh-home', refreshHome)
})
onBeforeUnmount(() => {
window.removeEventListener('refresh-home', refreshHome)
})
useScrollLoadMore(fetchContent)
watch([selectedCategory, selectedTags], () => {