diff --git a/src/forge/SoftwareFactory/components/Home/index.jsx b/src/forge/SoftwareFactory/components/Home/index.jsx index 892657e36..1fa905a16 100644 --- a/src/forge/SoftwareFactory/components/Home/index.jsx +++ b/src/forge/SoftwareFactory/components/Home/index.jsx @@ -10,6 +10,7 @@ import "slick-carousel/slick/slick.css"; import "slick-carousel/slick/slick-theme.css"; import Slider from "react-slick"; import RightContent from "./rightContent"; +import { getNewsAllList } from '../../../Information/api'; // let focuseWorkList = [ // { @@ -68,19 +69,32 @@ const setting = { }; function Home(props) { - const { newsList,timeObj,dayMap,weekMap,monthMap,weatherObj,currentMonth } = props; + const {id, newsList,timeObj,dayMap,weekMap,monthMap,weatherObj,currentMonth } = props; const [firstNews, setFirstNews] = useState({}); const [focuseWorkList, setFocuseWorkList] = useState([]); const rightContentDom = React.useRef(null) // const [focuseWorkList, setFocuseWorkList] = useState([]); + useEffect(()=>{ + let timer = null + if(id){ + getNewsList() + timer = setInterval(()=>{ + getNewsList() + },Number(localStorage.getItem('apiTime')) || 300000) + return () =>{ + clearInterval(timer) + } + } + },[id]) - - useEffect(() => { - if (newsList && newsList.length) { - // //重点工作 + function getNewsList() { + getNewsAllList(id).then(result => { + if (result && result.data.rows && result.data.rows.length) { + let rows = result.data.rows; + // //重点工作 let allList = []; - newsList.map((item) => { + rows.map((item) => { if (item.name === "开源中心要闻") { item.cmsDocList.map((item) => { allList.push(item); @@ -114,9 +128,9 @@ function Home(props) { } }); setFocuseWorkList(finalList); - } - }, newsList); - + } + }).catch(error => { }) + } return (