This commit is contained in:
Dawn1Ocean
2024-04-16 19:30:44 +08:00
parent a6d435a22f
commit 0ea7eff03d
5 changed files with 47 additions and 9 deletions
+20 -1
View File
@@ -1,9 +1,10 @@
import { getStat } from '@/services/api';
import type { TinyRingConfig } from '@ant-design/charts';
import { Tiny } from '@ant-design/charts';
import { PageContainer, ProCard, StatisticCard } from '@ant-design/pro-components';
import { Card, Statistic } from 'antd';
import RcResizeObserver from 'rc-resize-observer';
import { useState } from 'react';
import { useLayoutEffect, useState } from 'react';
const percentRing = (percent: number, frontColor: string): React.JSX.Element => {
const TinyRing = Tiny.Ring as (props: TinyRingConfig) => JSX.Element;
@@ -50,6 +51,24 @@ const indexData: IndexData = {
const Logs: React.FC = () => {
const [responsive, setResponsive] = useState(false);
const [todayPT, setTodayPT] = useState(0);
const [report, setReport] = useState(0);
const [oreo, setOreo] = useState(0);
const [totalPT, setTotalPT] = useState(0);
const [allSuccess, setAllSuccess] = useState(0);
const [all, setAll] = useState(0);
useLayoutEffect(() => {
getStat().then((res) => {
const data = res.data;
setTodayPT(data.todayPT);
setReport(data.report);
setOreo(data.oreo);
setTotalPT(data.totalPT);
setAllSuccess(data.allSuccess);
setAll(data.all);
})
});
return (
<PageContainer>
<Card style={{ color: '#f5f5f5' }}>
+10
View File
@@ -32,3 +32,13 @@ export async function login(body: API.LoginParams, options?: { [key: string]: an
...(options || {}),
});
}
/** 获取首页信息 GET /admin/stat */
export async function getStat(options?: { [key: string]: any }) {
return request<{
data: API.Stat;
}>('/stat', {
method: 'GET',
...(options || {}),
});
}
+8
View File
@@ -54,4 +54,12 @@ declare namespace API {
size: number;
data: LogsItem[];
};
type Stat = {
todayPT: number;
totalPT: number;
oreo: number;
report: number;
allSuccess: number;
all: number;
};
}