From 15691503fce4c8a085184b63dbbf405dd813bace Mon Sep 17 00:00:00 2001 From: shiyi <529977910@qq.com> Date: Tue, 19 Aug 2025 01:09:31 +0800 Subject: [PATCH 1/2] feat: Add Search Functionality --- src/components/common/SearchDialog.vue | 337 +++++++++++++++++++++++++ src/components/navs/Header.vue | 45 +++- 2 files changed, 378 insertions(+), 4 deletions(-) create mode 100644 src/components/common/SearchDialog.vue diff --git a/src/components/common/SearchDialog.vue b/src/components/common/SearchDialog.vue new file mode 100644 index 0000000..eadefcc --- /dev/null +++ b/src/components/common/SearchDialog.vue @@ -0,0 +1,337 @@ + + + + + \ No newline at end of file diff --git a/src/components/navs/Header.vue b/src/components/navs/Header.vue index e1f2663..bc0bed2 100644 --- a/src/components/navs/Header.vue +++ b/src/components/navs/Header.vue @@ -5,12 +5,27 @@ Logo - +
+ + + +
- + + +
+ @@ -88,9 +108,11 @@ import { CATEGORIES, NEW, UPDATED } from '../../constants/Categories'; import FadeContent from '../../content/Animations/FadeContent/FadeContent.vue'; import Logo from '../../assets/logos/vue-bits-logo.svg'; import Star from '../../assets/common/star.svg'; +import SearchDialog from '../common/SearchDialog.vue' const isDrawerOpen = ref(false); const isTransitioning = ref(false); +const isSearchOpen = ref(false) const stars = useStars(); const route = useRoute(); const router = useRouter(); @@ -132,6 +154,13 @@ const handleKeyDown = (e: KeyboardEvent) => { if (e.key === 'Escape' && isDrawerOpen.value) { closeDrawer(); } + if (e.key === '/' && !isSearchOpen.value) { + e.preventDefault() + openSearch() + } + if (e.key === 'Escape' && isSearchOpen.value) { + closeSearch() + } }; const Category = defineComponent({ @@ -224,6 +253,14 @@ const Category = defineComponent({ } }); +const openSearch = () => { + isSearchOpen.value = true +} + +const closeSearch = () => { + isSearchOpen.value = false +} + onMounted(() => { document.addEventListener('keydown', handleKeyDown); }); From 2cf0a0476fbfc9b33af195212c62888afe94b42d Mon Sep 17 00:00:00 2001 From: shiyi <529977910@qq.com> Date: Tue, 19 Aug 2025 17:41:06 +0800 Subject: [PATCH 2/2] fix: Change bg color and format --- src/components/common/SearchDialog.vue | 252 ++++++++++++++----------- src/css/sidebar.css | 4 +- 2 files changed, 146 insertions(+), 110 deletions(-) diff --git a/src/components/common/SearchDialog.vue b/src/components/common/SearchDialog.vue index eadefcc..03e7a91 100644 --- a/src/components/common/SearchDialog.vue +++ b/src/components/common/SearchDialog.vue @@ -1,48 +1,79 @@ \ No newline at end of file + diff --git a/src/css/sidebar.css b/src/css/sidebar.css index d79ad2f..357f157 100644 --- a/src/css/sidebar.css +++ b/src/css/sidebar.css @@ -380,11 +380,13 @@ align-items: center; gap: 0.25rem; font-size: 10px; - padding: 0 0.5rem; border-radius: 50px; background: #1a1a1a; color: #a6a6a6; border: 1px solid #333; + width: 20px; + height: 20px; + justify-content: center; } .star-count {