From 8a9b4e48674f6afef326e24ee941472b81f57853 Mon Sep 17 00:00:00 2001 From: yuruo Date: Mon, 24 Jun 2024 11:00:18 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D(Search/index.?= =?UTF-8?q?tsx)=EF=BC=9A=E5=88=A0=E9=99=A4=E6=9C=AA=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=9A=84useStore=E5=AF=BC=E5=85=A5=E5=92=8Csearch=E5=8F=98?= =?UTF-8?q?=E9=87=8F=20=F0=9F=94=A7=20=E6=9B=B4=E6=96=B0(useSearch.ts)?= =?UTF-8?q?=EF=BC=9A=E4=BC=98=E5=8C=96=E6=90=9C=E7=B4=A2=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=BB=98=E8=AE=A4=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=20=E2=99=BB=EF=B8=8F=20=E9=87=8D?= =?UTF-8?q?=E6=9E=84(useSearch.ts)=EF=BC=9A=E7=AE=80=E5=8C=96=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=AF=B9=E8=B1=A1=EF=BC=8C=E5=8E=BB=E9=99=A4=E4=B8=8D?= =?UTF-8?q?=E5=BF=85=E8=A6=81=E7=9A=84search=E5=8F=98=E9=87=8F=E5=92=8C?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E7=AE=A1=E7=90=86=E5=99=A8=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/renderer/src/components/Search/index.tsx | 3 --- ui/autoMate/src/renderer/src/hooks/useSearch.ts | 12 ++++++------ ui/autoMate/src/renderer/src/store/useStore.ts | 3 +-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/ui/autoMate/src/renderer/src/components/Search/index.tsx b/ui/autoMate/src/renderer/src/components/Search/index.tsx index dd118af..f5c0556 100644 --- a/ui/autoMate/src/renderer/src/components/Search/index.tsx +++ b/ui/autoMate/src/renderer/src/components/Search/index.tsx @@ -1,9 +1,7 @@ -import { useStore } from "@renderer/store/useStore" import useSearch from "@renderer/hooks/useSearch" import { SettingOne } from "@icon-park/react" import { Input } from "antd" export default function Search(): JSX.Element { - const search = useStore((state)=>state.search) const {handleSearch} = useSearch() return (
@@ -19,7 +17,6 @@ export default function Search(): JSX.Element { /> diff --git a/ui/autoMate/src/renderer/src/hooks/useSearch.ts b/ui/autoMate/src/renderer/src/hooks/useSearch.ts index 7e25e3e..c1f6a08 100644 --- a/ui/autoMate/src/renderer/src/hooks/useSearch.ts +++ b/ui/autoMate/src/renderer/src/hooks/useSearch.ts @@ -4,15 +4,15 @@ import { useStore } from "@renderer/store/useStore" export default()=>{ // const {setData} = useCode() const setData = useStore((state)=>state.setData) - // const [search, setSearch] = useState('') - const search = useStore((state)=>state.search) const handleSearch = async (e: ChangeEvent) => { + let inputValue = e.target.value ? e.target.value : "#####@@@@@@@@@@!$%^&&" const data = await window.api.sql( - `select * from contents where title like @content`, - 'findAll', - {content: `%${e.target.value}%`}) + `select * from contents where title like @content`, + 'findAll', + {content: `%${inputValue}%`}) + setData(data as ContentType[]) } - return {search, handleSearch} + return {handleSearch} } diff --git a/ui/autoMate/src/renderer/src/store/useStore.ts b/ui/autoMate/src/renderer/src/store/useStore.ts index 5ed5c06..a45dd12 100644 --- a/ui/autoMate/src/renderer/src/store/useStore.ts +++ b/ui/autoMate/src/renderer/src/store/useStore.ts @@ -1,9 +1,8 @@ -import { DataType } from "@renderer/data"; import { create } from "zustand"; interface StateProps{ config: ConfigDataType, setConfig: (config: ConfigDataType) => void, - data: DataType[], + data: ContentType[], setData: (data: ContentType[]) => void, search: string, setSearch: (search: string) => void,