Optimize code
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import React from 'react'
|
||||
import Icon from '@ant-design/icons'
|
||||
import * as echarts from 'echarts/core'
|
||||
import { useUpdatedEffect } from '@/util/hooks'
|
||||
@@ -8,7 +7,7 @@ import FlexBox from '@/components/common/FlexBox'
|
||||
import { getTooltipTimeFormatter, lineEChartsBaseOption } from '@/pages/System/Statistics/shared'
|
||||
import { CommonCard } from '@/pages/System/Statistics'
|
||||
|
||||
const ActiveInfo: React.FC = () => {
|
||||
const ActiveInfo = () => {
|
||||
const activeInfoDivRef = useRef<HTMLDivElement>(null)
|
||||
const activeInfoEChartsRef = useRef<echarts.EChartsType | null>(null)
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import React from 'react'
|
||||
import * as echarts from 'echarts/core'
|
||||
import { BarSeriesOption } from 'echarts/charts'
|
||||
import { useUpdatedEffect } from '@/util/hooks'
|
||||
@@ -11,7 +10,7 @@ import {
|
||||
} from '@/pages/System/Statistics/shared'
|
||||
import { CommonCard } from '@/pages/System/Statistics'
|
||||
|
||||
const CPUInfo: React.FC = () => {
|
||||
const CPUInfo = () => {
|
||||
const keyDivRef = useRef<HTMLDivElement>(null)
|
||||
const percentDivRef = useRef<HTMLDivElement>(null)
|
||||
const cpuInfoDivRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import React from 'react'
|
||||
import { useUpdatedEffect } from '@/util/hooks'
|
||||
import { r_sys_statistics_hardware } from '@/services/system'
|
||||
import FlexBox from '@/components/common/FlexBox'
|
||||
import { CommonCard } from '@/pages/System/Statistics'
|
||||
|
||||
const HardwareInfo: React.FC = () => {
|
||||
const HardwareInfo = () => {
|
||||
const [hardwareInfoData, setHardwareInfoData] = useState<HardwareInfoVo>()
|
||||
|
||||
useUpdatedEffect(() => {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import React from 'react'
|
||||
import Icon from '@ant-design/icons'
|
||||
import * as echarts from 'echarts/core'
|
||||
import { useUpdatedEffect } from '@/util/hooks'
|
||||
@@ -8,7 +7,7 @@ import FlexBox from '@/components/common/FlexBox'
|
||||
import { getTooltipTimeFormatter, lineEChartsBaseOption } from '@/pages/System/Statistics/shared'
|
||||
import { CommonCard } from '@/pages/System/Statistics'
|
||||
|
||||
const OnlineInfo: React.FC = () => {
|
||||
const OnlineInfo = () => {
|
||||
const onlineInfoDivRef = useRef<HTMLDivElement>(null)
|
||||
const onlineInfoEChartsRef = useRef<echarts.EChartsType | null>(null)
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import React from 'react'
|
||||
import { useUpdatedEffect } from '@/util/hooks'
|
||||
import { utcToLocalTime } from '@/util/datetime'
|
||||
import { r_sys_statistics_software } from '@/services/system'
|
||||
import FlexBox from '@/components/common/FlexBox'
|
||||
import { CommonCard } from '@/pages/System/Statistics'
|
||||
|
||||
const SoftwareInfo: React.FC = () => {
|
||||
const SoftwareInfo = () => {
|
||||
const [softwareInfoData, setSoftwareInfoData] = useState<SoftwareInfoVo>()
|
||||
|
||||
useUpdatedEffect(() => {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import * as echarts from 'echarts/core'
|
||||
import { BarSeriesOption } from 'echarts/charts'
|
||||
import { formatByteSize } from '@/util/common'
|
||||
@@ -12,7 +11,7 @@ import {
|
||||
} from '@/pages/System/Statistics/shared'
|
||||
import { CommonCard } from '@/pages/System/Statistics'
|
||||
|
||||
const StorageInfo: React.FC = () => {
|
||||
const StorageInfo = () => {
|
||||
const keyDivRef = useRef<HTMLDivElement>(null)
|
||||
const percentDivRef = useRef<HTMLDivElement>(null)
|
||||
const storageInfoDivRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react'
|
||||
import { PropsWithChildren, ReactNode } from 'react'
|
||||
import Icon from '@ant-design/icons'
|
||||
import '@/assets/css/pages/system/statistics.scss'
|
||||
import Card from '@/components/common/Card'
|
||||
@@ -14,14 +14,14 @@ import HardwareInfo from '@/pages/System/Statistics/HardwareInfo'
|
||||
import CPUInfo from '@/pages/System/Statistics/CPUInfo'
|
||||
import StorageInfo from '@/pages/System/Statistics/StorageInfo'
|
||||
|
||||
interface CommonCardProps extends React.PropsWithChildren {
|
||||
interface CommonCardProps extends PropsWithChildren {
|
||||
icon: IconComponent
|
||||
title: React.ReactNode
|
||||
title: ReactNode
|
||||
loading?: boolean
|
||||
expand?: React.ReactNode
|
||||
expand?: ReactNode
|
||||
}
|
||||
|
||||
export const CommonCard: React.FC<CommonCardProps> = (props) => {
|
||||
export const CommonCard = (props: CommonCardProps) => {
|
||||
return (
|
||||
<Card style={{ overflow: 'visible' }}>
|
||||
<FlexBox className={'common-card'}>
|
||||
@@ -41,7 +41,7 @@ export const CommonCard: React.FC<CommonCardProps> = (props) => {
|
||||
)
|
||||
}
|
||||
|
||||
const Statistics: React.FC = () => {
|
||||
const Statistics = () => {
|
||||
return (
|
||||
<>
|
||||
<FitFullscreen data-component={'system-statistics'}>
|
||||
|
||||
Reference in New Issue
Block a user