From 5ee3519c2175755ac89655ac350220ca85ee5d01 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Wed, 8 Dec 2021 10:11:13 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=A6=96=E9=A1=B5=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=90=9C=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/forge/Main/projecthome/Index.jsx | 31 ++++++++++++++++++++++++--- src/forge/Main/projecthome/Index.scss | 10 ++++++++- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/forge/Main/projecthome/Index.jsx b/src/forge/Main/projecthome/Index.jsx index 3d214010..3b56b455 100644 --- a/src/forge/Main/projecthome/Index.jsx +++ b/src/forge/Main/projecthome/Index.jsx @@ -4,18 +4,21 @@ import SubBanner from './SubBanner'; import SubUnitBanner from './SubUnitBanner'; import Icon from '../img/index/icon.png'; import { Link } from 'react-router-dom'; -import { Spin } from 'antd'; +import { Spin , Input } from 'antd'; import SubList from './SubList'; import more from '../img/index/more.png'; import axios from 'axios'; import { getImageUrl } from 'educoder'; import Nodata from '../../Nodata'; +const { Search } = Input; + const LIMIT = 20; function Index() { const [ cateList , setCateList ] = useState(undefined); const [ projectsList , setProjectsList ] = useState(undefined); + const [ search , setSearch ] = useState(undefined); const [ cateID, setCateID ] = useState(undefined); const [ isSpin, setIsSpin ] = useState(true); @@ -37,13 +40,14 @@ function Index() { }).catch(error=>{}) } - function getProject() { + function getProject(searchValue) { const url = `/projects.json`; axios.get(url,{ params:{ pinned:"d", category_id:cateID, - limit:LIMIT + limit:LIMIT, + search:searchValue } }).then(result=>{ if(result && result.data){ @@ -52,6 +56,15 @@ function Index() { } }).catch(error=>{}) } + + function changeSearchValue(e){ + setSearch(e.target.value); + } + + function searchFun(value){ + setIsSpin(true); + getProject(value); + } return(