2023-05-07 15:41:18 +00:00
|
|
|
<script setup lang="ts">
|
2024-04-01 05:24:42 +00:00
|
|
|
const keys = useMagicKeys()
|
2023-05-07 15:41:18 +00:00
|
|
|
const { t } = useI18n()
|
2024-04-01 05:24:42 +00:00
|
|
|
|
2023-05-07 15:41:18 +00:00
|
|
|
useHydratedHead({
|
|
|
|
title: () => t('nav.search'),
|
|
|
|
})
|
|
|
|
|
2024-02-21 15:20:08 +00:00
|
|
|
const search = ref<{ input?: HTMLInputElement }>()
|
2024-04-01 05:24:42 +00:00
|
|
|
|
2023-05-07 15:41:18 +00:00
|
|
|
watchEffect(() => {
|
2024-02-21 15:20:08 +00:00
|
|
|
if (search.value?.input)
|
|
|
|
search.value?.input?.focus()
|
2023-05-07 15:41:18 +00:00
|
|
|
})
|
2024-04-01 05:24:42 +00:00
|
|
|
onActivated(() => search.value?.input?.focus())
|
2024-02-21 15:20:08 +00:00
|
|
|
onDeactivated(() => search.value?.input?.blur())
|
2024-04-01 05:24:42 +00:00
|
|
|
|
|
|
|
watch(keys['/'], (v) => {
|
|
|
|
// focus on input when '/' is up to avoid '/' being typed
|
|
|
|
if (!v)
|
|
|
|
search.value?.input?.focus()
|
|
|
|
})
|
2023-05-07 15:41:18 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<MainContent>
|
|
|
|
<template #title>
|
|
|
|
<NuxtLink to="/search" timeline-title-style flex items-center gap-2 @click="$scrollToTop">
|
|
|
|
<div i-ri:search-line class="rtl-flip" />
|
|
|
|
<span>{{ $t('nav.search') }}</span>
|
|
|
|
</NuxtLink>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<div px2 mt3>
|
|
|
|
<SearchWidget v-if="isHydrated" ref="search" m-1 />
|
|
|
|
</div>
|
|
|
|
</MainContent>
|
|
|
|
</template>
|