From 5b6a6b6da20f387f7b931e74083a73b4e8b2d1c1 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Wed, 17 May 2023 10:22:10 +0800 Subject: [PATCH] bug --- src/App.js | 1 - src/home/TopEdition.jsx | 32 +++++++++++++++++--------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/App.js b/src/App.js index 094104ca..7fa85f83 100644 --- a/src/App.js +++ b/src/App.js @@ -323,7 +323,6 @@ class App extends Component { render() { const { pathType, pathName, mygetHelmetapi } = this.state; - console.log("dsf:",pathName); return ( diff --git a/src/home/TopEdition.jsx b/src/home/TopEdition.jsx index be243dd5..bb19619d 100644 --- a/src/home/TopEdition.jsx +++ b/src/home/TopEdition.jsx @@ -26,27 +26,29 @@ function TopEdition({register,current_user}) { const [ bannerList , setBannerList ] = useState(undefined); useEffect(()=>{ - // getBanner(); - let list = [ - { - id: 1, - image: xingBanner1, - title: "星云协同开发", - url: "" - } - ] - setBannerList(list); + getBanner(); },[]) function getBanner() { const url = `/topics.json?topic_type=banner`; axios.get(url,{ params:{ - limit:5 + limit:1 } }).then(result=>{ if(result){ - setBannerList(result.data.topics); + let topic = result.data.topics; + let list = [ + { + id:"1", + image:xingBanner1, + local:true, + title:"CCF开源创新平台", + url:"" + } + ] + const data= topic && topic.length>0?topic:list; + setBannerList(data); } }).catch(error=>{}) } @@ -57,9 +59,9 @@ function TopEdition({register,current_user}) { bannerList.map((i,k)=>{ return(
- {/* style={{backgroundImage:`url(${getImageUrl(i.image)})`}} */} -
{if(i.url){window.location.href=i.url}}} style={{cursor: i.url ? 'pointer' : ''}}> - + {/* onClick={()=>{if(i.url){window.location.href=i.url}}} */} +
+ {/* { k +1 === bannerList.length && (!(current_user && current_user.login)) ?

立即注册