diff --git a/src/pages/index/index.less b/src/pages/index/index.less index e69de29..ae83aea 100644 --- a/src/pages/index/index.less +++ b/src/pages/index/index.less @@ -0,0 +1,7 @@ +.flex{ + display: flex; + justify-content: space-around; +} +.card{ + margin-bottom: 30px; +} diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 7016320..5453cdd 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -1,10 +1,108 @@ -import React from 'react'; +import React, { useState, useEffect } from 'react'; import styles from './index.less'; +import { + getNoticeCount, + getRegulationsCount, + getCustomerQandaCount, + getLinksCount, +} from '@/servers/api'; +import { Row, Col, Card, Statistic, Space } from 'antd'; const IndexPage: React.FC = () => { + // 通知中心数量 + const [noticeCount, setNoticeCount] = useState({ + publishCount: 0, + topCount: 0, + totalCount: 0, + }); + // 政策法规数量 + const [regulationsCount, setRegulationsCount] = useState({ + publishCount: 0, + topCount: 0, + totalCount: 0, + }); + // 用户提问数量 + const [customerQandaCount, setCustomerQandaCount] = useState({ + noticeCount: 0, + resolvedCount: 0, + totalCount: 0, + }); + // 友情链接数量 + const [linksCount, setLinksCount] = useState({ + publishCount: 0, + totalCount: 0, + }); + + useEffect(() => { + // 政策法规数量 + getRegulationsCount().then((res) => { + setRegulationsCount(res.data); + }); + // 通知中心数量 + getNoticeCount().then((res) => { + setNoticeCount(res.data); + }); + // 用户提问数量 + getCustomerQandaCount().then((res) => { + setCustomerQandaCount(res.data); + }); + // 友情链接数量 + getLinksCount().then((res) => { + setLinksCount(res.data); + }); + }, []); + + const valueStyleBySuccess = { + color: '#3f8600', + fontSize: 40, + }; + const valueStyleByError = { + color: '#cf1322', + fontSize: 40, + }; + const valueStyleByWarning = { + color: '#faad14', + fontSize: 40, + }; return (