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 {