fix: 解决容器监控单位不正确的问题 (#3857)

Refs #3853
This commit is contained in:
ssongliu 2024-02-07 22:30:09 +08:00 committed by GitHub
parent 958f9a1aad
commit 6a903b7fdf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 2 deletions

View file

@ -5,7 +5,7 @@
import { onMounted, nextTick, watch, onBeforeUnmount } from 'vue';
import * as echarts from 'echarts';
import { GlobalStore } from '@/store';
import { computeSizeFromKBs, computeSizeFromMB } from '@/utils/util';
import { computeSizeFromKBs, computeSizeFromKB, computeSizeFromMB } from '@/utils/util';
const globalStore = GlobalStore();
const props = defineProps({
id: {
@ -141,6 +141,11 @@ function initChart() {
res += item.marker + ' ' + item.seriesName + '' + computeSizeFromKBs(item.data) + '<br/>';
}
break;
case 'KB':
for (const item of datas) {
res += item.marker + ' ' + item.seriesName + '' + computeSizeFromKB(item.data) + '<br/>';
}
break;
case 'MB':
for (const item of datas) {
res += item.marker + ' ' + item.seriesName + '' + computeSizeFromMB(item.data) + '<br/>';

View file

@ -166,6 +166,14 @@ export function computeSizeFromMB(size: number): string {
return (size / Math.pow(num, 3)).toFixed(2) + ' TB';
}
export function computeSizeFromKB(size: number): string {
const num = 1024.0;
if (size < num) return size + ' KB';
if (size < Math.pow(num, 2)) return (size / num).toFixed(2) + ' MB';
if (size < Math.pow(num, 3)) return (size / Math.pow(num, 2)).toFixed(2) + ' GB';
return (size / Math.pow(num, 3)).toFixed(2) + ' TB';
}
export function computeSizeFromKBs(size: number): string {
const num = 1024.0;
if (size < num) return size + ' KB/s';

View file

@ -215,7 +215,7 @@ const loadData = async () => {
data: netRxDatas.value,
},
],
formatStr: 'KB/s',
formatStr: 'KB',
};
};
const handleClose = async () => {