接口位置调整

This commit is contained in:
qiukai 2025-03-14 14:13:16 +08:00
parent 3cedb4befe
commit 242a6e8aa3
5 changed files with 138 additions and 162 deletions

View File

@ -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 (
<div className="center-panel">
<div className="first-section">

View File

@ -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 (
<div className="home-wrap">
@ -209,7 +173,7 @@ function Home(props) {
</div>
<div className="soft-title">软件工厂工作态势</div>
</div>
<RightContent timeObj={timeObj} ref={rightContentDom}/>
<RightContent dayMap={dayMap} weekMap={weekMap} monthMap={monthMap} timeObj={timeObj} ref={rightContentDom} weatherObj={weatherObj}/>
</div>
</div>
);

View File

@ -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 (
<div style={{ width: 1330, height: "100%" }}>
<Slider {...setting}>
@ -93,7 +53,7 @@ function RightContent(props) {
<ThirdPanel cardPage="1" dayMap={dayMap} ref={thirdDayDom}/>
<ForthPanel cardPage="1" dayMap={dayMap} ref={forthDayDom} />
</div>
<CenterPanel timeObj={timeObj} />
<CenterPanel timeObj={timeObj} weatherObj={weatherObj} ref={centerDom}/>
</div>
<div className="right-content" key="card2">
<div className="top-section">
@ -104,7 +64,7 @@ function RightContent(props) {
<ThirdPanel cardPage="2" monthMap={monthMap} ref={thirdmonthDom} />
<ForthPanel cardPage="2" monthMap={monthMap} ref={forthmonthDom} />
</div>
<CenterPanel timeObj={timeObj} ref={centerDom}/>
<CenterPanel timeObj={timeObj} weatherObj={weatherObj} ref={centerDom}/>
</div>
</Slider>
</div>

View File

@ -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:

View File

@ -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 (<div className="softFc-wrap">
<Slider {...setting} >
<Home newsList={newsList} key="home" ref={homeDom}/>
<ProjectStatus key="project" ref={proDom}/>
<Home newsList={newsList} timeObj={timeObj} dayMap={dayMap} weekMap={weekMap} monthMap={monthMap} weatherObj={weatherObj} currentMonth={currentMonth} key="home" ref={homeDom}/>
<ProjectStatus key="project" ref={proDom} projectList={projectList}/>
</Slider>
</div>)
}