diff --git a/src/global.d.ts b/src/global.d.ts index e51602e..6856688 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -385,3 +385,7 @@ interface OnlineInfoVo { record: string }[] } + +interface OnlineInfoGetParam { + scope: string +} diff --git a/src/pages/system/index.tsx b/src/pages/system/index.tsx index 55e65dd..16d688c 100644 --- a/src/pages/system/index.tsx +++ b/src/pages/system/index.tsx @@ -156,6 +156,7 @@ const OnlineInfo: React.FC = () => { const onlineInfoEChartsRef = useRef(null) const [isLoading, setIsLoading] = useState(false) const [currentOnlineCount, setCurrentOnlineCount] = useState(-1) + const [scope, setScope] = useState('WEAK') useUpdatedEffect(() => { const chartResizeObserver = new ResizeObserver(() => { @@ -173,14 +174,23 @@ const OnlineInfo: React.FC = () => { getOnlineInfo() }, []) - const getOnlineInfo = () => { + const handleOnScopeChange = (value: string) => { + setScope(value) + getOnlineInfo(value) + } + + const handleOnRefresh = () => { + getOnlineInfo() + } + + const getOnlineInfo = (_scope: string = scope) => { if (isLoading) { return } setIsLoading(true) - void r_sys_statistic_online().then((res) => { + void r_sys_statistic_online({ scope: _scope }).then((res) => { const response = res.data if (response.success) { const data = response.data @@ -224,15 +234,30 @@ const OnlineInfo: React.FC = () => { <> 在线用户 - 当前 {currentOnlineCount} + + 当前 {currentOnlineCount === -1 ? '获取中...' : currentOnlineCount} + } loading={isLoading} expand={ - getOnlineInfo()}> - - + <> + + 今天 + 最近7天 + 最近30天 + 最近3个月 + 最近12个月 + 最近2年 + 最近3年 + 最近5年 + 全部 + + + + + } > diff --git a/src/services/system.tsx b/src/services/system.tsx index 5945a13..8686e6e 100644 --- a/src/services/system.tsx +++ b/src/services/system.tsx @@ -88,4 +88,5 @@ export const r_sys_statistic_cpu = () => request.get(URL_SYS_STATISTI export const r_sys_statistic_storage = () => request.get(URL_SYS_STATISTIC_STORAGE) -export const r_sys_statistic_online = () => request.get(URL_SYS_STATISTIC_ONLINE) +export const r_sys_statistic_online = (param: OnlineInfoGetParam) => + request.get(URL_SYS_STATISTIC_ONLINE, param)