diff --git a/packages/web/projects/vgpu/components/previewBar.vue b/packages/web/projects/vgpu/components/previewBar.vue index 880264c..797f031 100644 --- a/packages/web/projects/vgpu/components/previewBar.vue +++ b/packages/web/projects/vgpu/components/previewBar.vue @@ -57,14 +57,14 @@ const echartsRef = ref(); const totalTop = { title: `${props.title}资源分配率 Top5`, config: [ - { + props.type === 'node' && { tab: 'CPU', key: 'cpu', nameKey: 'instance', data: [], query: `topk(5, sum(hami_container_vcore_allocated) by (instance) / sum(hami_core_size) by (instance) * 100)`, }, - { + props.type === 'node' && { tab: '内存', key: 'internal', nameKey: 'instance', @@ -92,21 +92,20 @@ const totalTop = { nameKey: props.type, query: `topk(5, sum(hami_container_vmemory_allocated{}) by (${props.type}) / sum(hami_memory_size{}) by (${props.type}) * 100)`, }, - ], + ].filter(Boolean), }; const usedTop = { title: `${props.title}资源使用率 Top5`, config: [ - { + props.type === 'node' && { tab: 'CPU', key: 'cpu', nameKey: 'instance', data: [], - query: `topk(5, (1 - avg(rate(node_cpu_seconds_total{mode="idle"}[5m])) by (instance)) * 100) -`, + query: `topk(5, (1 - avg(rate(node_cpu_seconds_total{mode="idle"}[5m])) by (instance)) * 100)`, }, - { + props.type === 'node' && { tab: '内存', key: 'internal', nameKey: 'instance', @@ -127,7 +126,7 @@ const usedTop = { nameKey: props.type, query: `topk(5, sum(hami_memory_used) by (${props.type}) / sum(hami_memory_size) by (${props.type}) * 100)`, }, - ], + ].filter(Boolean), }; const pieConfig = {