Skip to content

Commit a6e66c3

Browse files
committed
fix: 导航搜索面板唤起时输入框未聚焦
1 parent 2080d0b commit a6e66c3

File tree

1 file changed

+5
-2
lines changed
  • src/layouts/components/Topbar/Toolbar/NavSearch

1 file changed

+5
-2
lines changed

src/layouts/components/Topbar/Toolbar/NavSearch/search.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import useMenuStore from '@/store/modules/menu'
66
import useRouteStore from '@/store/modules/route'
77
import useSettingsStore from '@/store/modules/settings'
88
import { resolveRoutePath } from '@/utils'
9+
import { useFocus } from '@vueuse/core'
910
import hotkeys from 'hotkeys-js'
1011
1112
defineOptions({
@@ -29,6 +30,8 @@ interface listTypes {
2930
}
3031
3132
const searchInput = ref('')
33+
const searchInputRef = useTemplateRef('searchInputRef')
34+
const { focused: searchInputFocused } = useFocus(searchInputRef)
3235
const sourceList = ref<listTypes[]>([])
3336
const actived = ref(-1)
3437
@@ -197,13 +200,13 @@ function pageJump(path: listTypes['path'], link: listTypes['link']) {
197200
</script>
198201

199202
<template>
200-
<FaModal ref="searchResultRef" v-model="isShow" border :footer="settingsStore.mode === 'pc'" :closable="false" class="w-full lg-max-w-2xl" content-class="flex flex-col p-0 min-h-auto" header-class="p-0" footer-class="p-0">
203+
<FaModal ref="searchResultRef" v-model="isShow" border :footer="settingsStore.mode === 'pc'" :closable="false" class="w-full lg-max-w-2xl" content-class="flex flex-col p-0 min-h-auto" header-class="p-0" footer-class="p-0" @opened="searchInputFocused = true">
201204
<template #header>
202205
<div class="h-12 flex flex-shrink-0 items-center">
203206
<div class="h-full w-14 flex-center">
204207
<FaIcon name="i-ri:search-line" class="size-4 text-foreground/30" />
205208
</div>
206-
<input v-model="searchInput" placeholder="搜索页面,支持标题、URL模糊查询" class="h-full w-full border-0 rounded-md bg-transparent text-base text-foreground focus-outline-none placeholder-foreground/30" @keydown.esc="isShow = false" @keydown.up.prevent="keyUp" @keydown.down.prevent="keyDown" @keydown.enter.prevent="keyEnter">
209+
<input ref="searchInputRef" v-model="searchInput" placeholder="搜索页面,支持标题、URL模糊查询" class="h-full w-full border-0 rounded-md bg-transparent text-base text-foreground focus-outline-none placeholder-foreground/30" @keydown.esc.prevent="isShow = false" @keydown.up.prevent="keyUp" @keydown.down.prevent="keyDown" @keydown.enter.prevent="keyEnter">
207210
<div v-if="settingsStore.mode === 'mobile'" class="h-full w-14 flex-center border-s">
208211
<FaIcon name="i-carbon:close" class="size-4" @click="isShow = false" />
209212
</div>

0 commit comments

Comments
 (0)