From 10dc64a8c36e1c244b1f485f7afb335933a70d98 Mon Sep 17 00:00:00 2001
From: zhuba-Ahhh <3477826311@qq.com>
Date: Tue, 15 Oct 2024 19:22:09 +0800
Subject: [PATCH] =?UTF-8?q?chore:=20:hammer:=20=E6=90=9C=E7=B4=A2=E6=A1=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/Navbar.tsx | 6 +-----
src/components/Search.tsx | 6 +++---
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx
index cd00743..17470c6 100644
--- a/src/components/Navbar.tsx
+++ b/src/components/Navbar.tsx
@@ -10,11 +10,7 @@ const Navbar = () => {
- console.log(event.target.value)}
- className="mr-2"
- />
+
{[
{ name: '剑来', path: '/' },
{ name: '雪中', path: '/xuezhong' },
diff --git a/src/components/Search.tsx b/src/components/Search.tsx
index a1cae2d..a943773 100644
--- a/src/components/Search.tsx
+++ b/src/components/Search.tsx
@@ -7,7 +7,7 @@ import { http, truncateString } from 'utils';
export type SearchInputProps = {
placeholder?: string; // 输入框的占位符文本
- onSearch: (event: ChangeEvent) => void; // 用户输入时触发的回调函数
+ onSearch?: (event: ChangeEvent) => void; // 用户输入时触发的回调函数
className?: string; // 额外的类名
style?: React.CSSProperties; // 额外的内联样式
};
@@ -19,7 +19,7 @@ type ResSearchSuggest = {
const SearchInput: React.FC = ({
placeholder = '输入关键词...',
- onSearch,
+ onSearch = () => {},
className = '',
style = {},
}) => {
@@ -53,7 +53,7 @@ const SearchInput: React.FC = ({
const value = event.target.value;
setInputValue(value);
- onSearch(event);
+ onSearch && onSearch(event);
if (value) {
fetchSearchResults(value);
} else {