From 1621cb920bddba0fd41e940be71e21f663048c04 Mon Sep 17 00:00:00 2001 From: ZLY Date: Thu, 22 Jan 2026 14:24:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(compLibrary):=20=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E5=A4=8D=E5=90=88=E7=BB=84=E4=BB=B6=E5=BA=93=E7=9A=84=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/compositeCompLibrary/compGrid.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pages/compositeCompLibrary/compGrid.tsx b/src/pages/compositeCompLibrary/compGrid.tsx index 96f4171..e40987c 100644 --- a/src/pages/compositeCompLibrary/compGrid.tsx +++ b/src/pages/compositeCompLibrary/compGrid.tsx @@ -16,6 +16,7 @@ interface CompGridProps { const CompGrid: React.FC = ({ componentType }) => { const [compData, setCompData] = useState([]); const [paginationData, setPaginationData] = useState({ totalCount: 0, currPage: 1, pageSize: 11 }); + const [searchKeyword, setSearchKeyword] = useState(''); useEffect(() => { if (componentType) getComponentData(componentType); @@ -28,7 +29,8 @@ const CompGrid: React.FC = ({ componentType }) => { }; const res: any = await apiList[key]({ currPage: paginationData.currPage, - pageSize: paginationData.pageSize + pageSize: paginationData.pageSize, + name: searchKeyword }); if (res.code === 200) { @@ -44,7 +46,15 @@ const CompGrid: React.FC = ({ componentType }) => { useEffect(() => { getComponentData(componentType); - }, [paginationData.currPage]); + }, [paginationData.currPage, searchKeyword]); + + const handleSearch = (value: string) => { + setSearchKeyword(value); + setPaginationData({ + ...paginationData, + currPage: 1 + }); + }; return ( <> @@ -53,6 +63,8 @@ const CompGrid: React.FC = ({ componentType }) => { searchButton="搜索" placeholder="请输入名字" style={{ width: 350 }} + onSearch={handleSearch} + allowClear /> {compData.map((v, i) => {