mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-01-04 05:56:04 +08:00
parent
958f9a1aad
commit
6a903b7fdf
3 changed files with 15 additions and 2 deletions
|
|
@ -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/>';
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ const loadData = async () => {
|
|||
data: netRxDatas.value,
|
||||
},
|
||||
],
|
||||
formatStr: 'KB/s',
|
||||
formatStr: 'KB',
|
||||
};
|
||||
};
|
||||
const handleClose = async () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue