2023-05-08 00:41:18 +09:00
|
|
|
<script setup lang="ts">
|
2024-04-01 14:24:42 +09:00
|
|
|
const keys = useMagicKeys()
|
2023-05-08 00:41:18 +09:00
|
|
|
const { t } = useI18n()
|
2024-04-01 14:24:42 +09:00
|
|
|
|
2023-05-08 00:41:18 +09:00
|
|
|
useHydratedHead({
|
|
|
|
title: () => t('nav.search'),
|
|
|
|
})
|
|
|
|
|
2024-02-22 00:20:08 +09:00
|
|
|
const search = ref<{ input?: HTMLInputElement }>()
|
2024-04-01 14:24:42 +09:00
|
|
|
|
2023-05-08 00:41:18 +09:00
|
|
|
watchEffect(() => {
|
2024-02-22 00:20:08 +09:00
|
|
|
if (search.value?.input)
|
|
|
|
search.value?.input?.focus()
|
2023-05-08 00:41:18 +09:00
|
|
|
})
|
2024-04-01 14:24:42 +09:00
|
|
|
onActivated(() => search.value?.input?.focus())
|
2024-02-22 00:20:08 +09:00
|
|
|
onDeactivated(() => search.value?.input?.blur())
|
2024-04-01 14:24:42 +09:00
|
|
|
|
|
|
|
watch(keys['/'], (v) => {
|
|
|
|
// focus on input when '/' is up to avoid '/' being typed
|
|
|
|
if (!v)
|
|
|
|
search.value?.input?.focus()
|
|
|
|
})
|
2023-05-08 00:41:18 +09: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>
|