Skip to content

Commit

Permalink
fix: add tab menu when user search menu
Browse files Browse the repository at this point in the history
  • Loading branch information
flingyp committed Jun 11, 2023
1 parent 3604786 commit 999850c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
32 changes: 19 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/layout/components/layout/BaseSearchItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ interface BaseSearchItemProps {
const props = defineProps<BaseSearchItemProps>()
const emit = defineEmits(['close'])
const routeKey = props.menu.key as string
const router = useRouter()
const routeMenuStore = useRouteMenuStore()
const navigatorTo = () => {
router.push({ name: (props.menu.key as string) })
routeMenuStore.createTabMenuKey(routeKey)
router.push({ name: routeKey })
emit('close')
}
</script>
Expand Down
11 changes: 4 additions & 7 deletions src/layout/components/layout/BaseSearchMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ const showSearchMenu = () => {
isShowSearchMenu.value = true
}
const closeSearchMenu = (type: 'CLICK' | 'BLUR') => {
if (type === 'CLICK') {
isShowSearchMenu.value = false
searchKeyWord.value = ''
} else if (type === 'BLUR') {
isShowSearchMenu.value = false
}
isShowSearchMenu.value = false
if (type === 'CLICK') searchKeyWord.value = ''
}
const inputKeywordRef = ref<HTMLInputElement>()
Expand All @@ -55,14 +51,15 @@ watch(defaultLocales, () => {
}, { immediate: true })
const inputKeyword = useDebounce(() => {
// 去除字符串里的空格
// remove all Spaces in the string
searchKeyWord.value = searchKeyWord.value.replace(/\s*/g, '')
const searchResult = fuse.search(searchKeyWord.value)
// @ts-ignore
searchMenuList.value = searchResult.map((data) => data.item)
}, 200)
</script>

<template>
<div class="flex items-center">
<NInput
Expand Down

0 comments on commit 999850c

Please sign in to comment.