From 074975271356238fe1e0cfa6741dfdaa5b2eec79 Mon Sep 17 00:00:00 2001 From: qiukai <123@qq.com> Date: Sat, 15 Mar 2025 11:39:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A6=81=E9=97=BB=E7=BA=BF=E4=B8=8A=E4=B8=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SoftwareFactory/components/Home/index.jsx | 32 +++++++++++++------ .../components/ProjectStatus/index.scss | 2 +- src/forge/SoftwareFactory/index.jsx | 25 ++------------- 3 files changed, 26 insertions(+), 33 deletions(-) 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 (