feat: remove sec field
This commit is contained in:
parent
f736951fc8
commit
8d7ef0dc94
@ -54,7 +54,7 @@ const Traffic = () => {
|
|||||||
color={+up > 0 ? "primary" : "disabled"}
|
color={+up > 0 ? "primary" : "disabled"}
|
||||||
/>
|
/>
|
||||||
<Typography {...valStyle}>{up}</Typography>
|
<Typography {...valStyle}>{up}</Typography>
|
||||||
<Typography {...unitStyle}>{upUnit}</Typography>
|
<Typography {...unitStyle}>{upUnit}/s</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box display="flex" alignItems="center" whiteSpace="nowrap">
|
<Box display="flex" alignItems="center" whiteSpace="nowrap">
|
||||||
@ -63,7 +63,7 @@ const Traffic = () => {
|
|||||||
color={+down > 0 ? "primary" : "disabled"}
|
color={+down > 0 ? "primary" : "disabled"}
|
||||||
/>
|
/>
|
||||||
<Typography {...valStyle}>{down}</Typography>
|
<Typography {...valStyle}>{down}</Typography>
|
||||||
<Typography {...unitStyle}>{downUnit}</Typography>
|
<Typography {...unitStyle}>{downUnit}/s</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* parse the traffic to
|
||||||
|
* xxx B
|
||||||
|
* xxx KB
|
||||||
|
* xxx MB
|
||||||
|
* xxx GB
|
||||||
|
*/
|
||||||
const parseTraffic = (num: number) => {
|
const parseTraffic = (num: number) => {
|
||||||
const gb = 1024 ** 3;
|
const gb = 1024 ** 3;
|
||||||
const mb = 1024 ** 2;
|
const mb = 1024 ** 2;
|
||||||
@ -5,7 +12,7 @@ const parseTraffic = (num: number) => {
|
|||||||
let t = num;
|
let t = num;
|
||||||
let u = "B";
|
let u = "B";
|
||||||
|
|
||||||
if (num < 1000) return [`${Math.round(t)}`, "B/s"];
|
if (num < 1000) return [`${Math.round(t)}`, "B"];
|
||||||
if (num <= mb) {
|
if (num <= mb) {
|
||||||
t = num / kb;
|
t = num / kb;
|
||||||
u = "KB";
|
u = "KB";
|
||||||
@ -16,8 +23,8 @@ const parseTraffic = (num: number) => {
|
|||||||
t = num / gb;
|
t = num / gb;
|
||||||
u = "GB";
|
u = "GB";
|
||||||
}
|
}
|
||||||
if (t >= 100) return [`${Math.round(t)}`, `${u}/s`];
|
if (t >= 100) return [`${Math.round(t)}`, u];
|
||||||
return [`${Math.round(t * 10) / 10}`, `${u}/s`];
|
return [`${Math.round(t * 10) / 10}`, u];
|
||||||
};
|
};
|
||||||
|
|
||||||
export default parseTraffic;
|
export default parseTraffic;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user