diff --git a/src/forge/SoftwareFactory/components/Home/centerPanel.jsx b/src/forge/SoftwareFactory/components/Home/centerPanel.jsx index 6fcfd6c15..43ba5c31a 100644 --- a/src/forge/SoftwareFactory/components/Home/centerPanel.jsx +++ b/src/forge/SoftwareFactory/components/Home/centerPanel.jsx @@ -5,50 +5,9 @@ import shidu from "../../img/shidu.png"; import ziwaixian from "../../img/ziwaixian.png"; function CenterPanel(props) { - let { timeObj } = props; - const [weatherObj, setWetherObj] = useState({}); - useEffect(() => { - const timer = setInterval(() => { - //天气5分钟更新一次 - getWether(); - }, Number(localStorage.getItem('apiTime')) || 300000); - getWether(); - return () => { - clearInterval(timer); - }; - }, []); - - function getWether() { - // fxLink 当前数据的响应式页面,便于嵌入网站或应用 - // now.obsTime 数据观测时间 - // now.temp 温度,默认单位:摄氏度 - // now.feelsLike 体感温度,默认单位:摄氏度 - // now.icon 天气状况的图标代码,另请参考天气图标项目 - // now.text 天气状况的文字描述,包括阴晴雨雪等天气状态的描述 - // now.wind360 风向360角度 - // now.windDir 风向 - // now.windScale 风力等级 - // now.windSpeed 风速,公里/小时 - // now.humidity 相对湿度,百分比数值 - // now.precip 过去1小时降水量,默认单位:毫米 - // now.pressure 大气压强,默认单位:百帕 - // now.vis 能见度,默认单位:公里 - // now.cloud 云量,百分比数值。可能为空 - // now.dew 露点温度。可能为空 - fetch( - `https://devapi.qweather.com/v7/weather/now?location=112.87,28.22&key=18a193299e4944a7bf3ccf23b38474c2` - ) - .then((response) => response.json()) - .then((data) => { - setWetherObj({ - text: data.now.text, - temp: data.now.temp, - windDir: data.now.windDir, - humidity: data.now.humidity, - }); - }) - .catch((err) => {}); - } + let { timeObj,weatherObj } = props; + + return (
diff --git a/src/forge/SoftwareFactory/components/Home/index.jsx b/src/forge/SoftwareFactory/components/Home/index.jsx index ce919e557..892657e36 100644 --- a/src/forge/SoftwareFactory/components/Home/index.jsx +++ b/src/forge/SoftwareFactory/components/Home/index.jsx @@ -10,8 +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 { getLunar } from "../../utils"; -import { todayWorkSituation,weekMonthWorkSituation} from "../../api"; + // let focuseWorkList = [ // { // name: "page1", @@ -59,7 +58,7 @@ const setting = { slidesToShow: 1, slidesToScroll: 1, pauseOnDotsHover: true, - autoplaySpeed: Number(localStorage.getItem('homeLoopSpeed')) || 5000, + autoplaySpeed: Number(localStorage.getItem('homeLoopSpeed')) || 8000, pauseOnFocus: true, autoplay: true, arrows: true, @@ -69,24 +68,12 @@ const setting = { }; function Home(props) { - const { newsList } = props; - const [currentMonth, setCurrentMonth] = useState(""); - const [timeObj, setTimeObj] = useState({}); + const { 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(() => { - getDay() - const timer = setInterval(() => { - //默认5分钟更新一次 - getDay(); - }, Number(localStorage.getItem('apiTime')) || 300000); - return () => { - clearInterval(timer); - }; - }, []); useEffect(() => { @@ -129,30 +116,7 @@ function Home(props) { setFocuseWorkList(finalList); } }, newsList); - function getDay() { - //获取日期数据 - const days = [ - "星期日", - "星期一", - "星期二", - "星期三", - "星期四", - "星期五", - "星期六", - ]; - let time = new Date(); - let year = time.getFullYear(); - let month = time.getMonth() + 1; - let day = time.getDate(); - let obj = { - month: month < 10 ? "0" + month : month.toString(), - day: day < 10 ? "0" + day : day.toString(), - week: days[time.getDay()], - lunar: getLunar(time), - }; - setCurrentMonth(`${year}年${month}月`); - setTimeObj(obj); - } + return (
@@ -209,7 +173,7 @@ function Home(props) {
软件工厂工作态势
- +
); diff --git a/src/forge/SoftwareFactory/components/Home/rightContent.jsx b/src/forge/SoftwareFactory/components/Home/rightContent.jsx index 2d829d41e..9c1596d14 100644 --- a/src/forge/SoftwareFactory/components/Home/rightContent.jsx +++ b/src/forge/SoftwareFactory/components/Home/rightContent.jsx @@ -7,7 +7,7 @@ import SecondPanel from "./secondPanel"; import ThirdPanel from "./thirdPanel"; import ForthPanel from "./forthPanel"; import CenterPanel from "./centerPanel"; -import { todayWorkSituation, weekMonthWorkSituation } from "../../api"; + const setting = { dots: false, infinite: true, @@ -15,7 +15,7 @@ const setting = { slidesToShow: 1, slidesToScroll: 1, pauseOnDotsHover: false, - autoplaySpeed: Number(localStorage.getItem("pageLoopSpeed")) || 8000, + autoplaySpeed: Number(localStorage.getItem("homeLoopSpeed")) || 8000, pauseOnFocus: false, autoplay: true, arrows: false, @@ -26,10 +26,7 @@ const setting = { // afterChange: (index) => setTag(index), }; function RightContent(props) { - const { timeObj } = props; - const [dayMap, setDayMap] = useState({}); - const [weekMap, setWeekMap] = useState({}); - const [monthMap, setMonthMap] = useState({}); + const { timeObj,dayMap,weekMap,monthMap,weatherObj } = props; const firstDayDom = React.useRef(null); const firstweekDom = React.useRef(null); const secondDayDom = React.useRef(null); @@ -40,44 +37,7 @@ function RightContent(props) { const forthmonthDom = React.useRef(null); const centerDom = React.useRef(null); - useEffect(() => { - getTodayData(); - getWeekData(); - getMonthData(); - const timer = setInterval(() => { - //5分钟更新一次 - getTodayData(); - getWeekData(); - getMonthData(); - }, Number(localStorage.getItem("apiTime")) || 300000); - return () => { - clearInterval(timer); - }; - }, []); - - function getTodayData() { - todayWorkSituation().then((res) => { - if (res.data.code === 200) { - setDayMap(res.data.data); - } - }); - } - - function getWeekData() { - weekMonthWorkSituation("week").then((res) => { - if (res.data.code === 200) { - setWeekMap(res.data.data); - } - }); - } - - function getMonthData() { - weekMonthWorkSituation("month").then((res) => { - if (res.data.code === 200) { - setMonthMap(res.data.data); - } - }); - } + return (
@@ -93,7 +53,7 @@ function RightContent(props) {
- +
@@ -104,7 +64,7 @@ function RightContent(props) {
- +
diff --git a/src/forge/SoftwareFactory/components/ProjectStatus/index.jsx b/src/forge/SoftwareFactory/components/ProjectStatus/index.jsx index aa46fae9f..728c9aaee 100644 --- a/src/forge/SoftwareFactory/components/ProjectStatus/index.jsx +++ b/src/forge/SoftwareFactory/components/ProjectStatus/index.jsx @@ -4,38 +4,10 @@ import { withRouter } from "react-router"; import centerBg from "../../img/center_title_bg.png"; import "./index.scss"; import ProjectCard from "./ProjectCard"; -import { projectSituation } from "../../api"; function ProjectStatus(props) { - const {} = props; - const [projectList, setProjectList] = useState([]); - + const {projectList} = props; const ProjectCardDom = React.useRef(null) - - useEffect(() => { - getProjectList(); - //项目信息五分钟更新一次 - let timer = setInterval(()=>{ - getProjectList(); - }, Number(localStorage.getItem('apiTime')) || 300000) - return ()=>{ - clearInterval(timer) - } - - }, []); - - function getProjectList() { - projectSituation().then((res) => { - if (res.data.code === 200) { - let list = - res.data.data.length > 10 - ? res.data.data.slice(0, 10) - : res.data.data; - setProjectList(list); - } - }); - } - function getShadowCls(idx) { switch (idx) { case 5: diff --git a/src/forge/SoftwareFactory/index.jsx b/src/forge/SoftwareFactory/index.jsx index b7e279dbd..9de4ea562 100644 --- a/src/forge/SoftwareFactory/index.jsx +++ b/src/forge/SoftwareFactory/index.jsx @@ -10,6 +10,8 @@ import { getNewsAllList, getMainInfos } from '../Information/api'; import next from "./img/next.png"; import Slider from "react-slick"; import './index.scss'; +import { getLunar } from "./utils"; +import { todayWorkSituation, weekMonthWorkSituation,projectSituation } from "./api"; const setting = { dots: false, infinite: true, @@ -37,8 +39,34 @@ function Index(props){ const [newsList,setNewsList] = useState([]) const homeDom = React.useRef(null) const proDom = React.useRef(null) + const [timeObj, setTimeObj] = useState({}); + const [dayMap, setDayMap] = useState({}); + const [weekMap, setWeekMap] = useState({}); + const [monthMap, setMonthMap] = useState({}); + const [weatherObj, setWetherObj] = useState({}); + const [currentMonth, setCurrentMonth] = useState(""); + const [projectList, setProjectList] = useState([]); + useEffect(()=>{ getId() + getDay() + getTodayData(); + getWeekData(); + getMonthData(); + getWether(); + getProjectList(); + const timer = setInterval(() => { + //默认5分钟更新一次 + getTodayData(); + getWeekData(); + getMonthData(); + getDay(); + getWether(); + getProjectList(); + }, Number(localStorage.getItem('apiTime')) || 300000); + return () => { + clearInterval(timer); + }; },[]) useEffect(()=>{ @@ -75,10 +103,103 @@ function Index(props){ }).catch(console.error()) } + function getWether() { + // fxLink 当前数据的响应式页面,便于嵌入网站或应用 + // now.obsTime 数据观测时间 + // now.temp 温度,默认单位:摄氏度 + // now.feelsLike 体感温度,默认单位:摄氏度 + // now.icon 天气状况的图标代码,另请参考天气图标项目 + // now.text 天气状况的文字描述,包括阴晴雨雪等天气状态的描述 + // now.wind360 风向360角度 + // now.windDir 风向 + // now.windScale 风力等级 + // now.windSpeed 风速,公里/小时 + // now.humidity 相对湿度,百分比数值 + // now.precip 过去1小时降水量,默认单位:毫米 + // now.pressure 大气压强,默认单位:百帕 + // now.vis 能见度,默认单位:公里 + // now.cloud 云量,百分比数值。可能为空 + // now.dew 露点温度。可能为空 + fetch( + `https://devapi.qweather.com/v7/weather/now?location=112.87,28.22&key=18a193299e4944a7bf3ccf23b38474c2` + ) + .then((response) => response.json()) + .then((data) => { + setWetherObj({ + text: data.now.text, + temp: data.now.temp, + windDir: data.now.windDir, + humidity: data.now.humidity, + }); + }) + .catch((err) => {}); + } + + function getTodayData() { + todayWorkSituation().then((res) => { + if (res.data.code === 200) { + setDayMap(res.data.data); + } + }); + } + + function getWeekData() { + weekMonthWorkSituation("week").then((res) => { + if (res.data.code === 200) { + setWeekMap(res.data.data); + } + }); + } + + function getMonthData() { + weekMonthWorkSituation("month").then((res) => { + if (res.data.code === 200) { + setMonthMap(res.data.data); + } + }); + } + + function getProjectList() { + projectSituation().then((res) => { + if (res.data.code === 200) { + let list = + res.data.data.length > 10 + ? res.data.data.slice(0, 10) + : res.data.data; + setProjectList(list); + } + }); + } + + function getDay() { + //获取日期数据 + const days = [ + "星期日", + "星期一", + "星期二", + "星期三", + "星期四", + "星期五", + "星期六", + ]; + let time = new Date(); + let year = time.getFullYear(); + let month = time.getMonth() + 1; + let day = time.getDate(); + let obj = { + month: month < 10 ? "0" + month : month.toString(), + day: day < 10 ? "0" + day : day.toString(), + week: days[time.getDay()], + lunar: getLunar(time), + }; + setCurrentMonth(`${year}年${month}月`); + setTimeObj(obj); + } + return (
- - + +
) }