diff --git a/src/views/link/DashBoard/components/Cpu.vue b/src/views/link/DashBoard/components/Cpu.vue index fbe6b86d..0d47222a 100644 --- a/src/views/link/DashBoard/components/Cpu.vue +++ b/src/views/link/DashBoard/components/Cpu.vue @@ -61,6 +61,13 @@ import { } from './tool.ts'; import { DataType } from '../typings'; +const props = defineProps({ + serviceId: { + type: String, + default: undefined + } +}) + const chartRef = ref>({}); const loading = ref(false); const data = ref({ @@ -79,7 +86,8 @@ const getCPUEcharts = async (val: any) => { const _cpuOptions = {}; const _cpuXAxis = new Set(); if (res.result?.length) { - res.result.forEach((item: any) => { + const filterArray = res.result.filter((item : any) => item.data?.clusterNodeId === props.serviceId) + filterArray.forEach((item: any) => { const value = item.data.value; const nodeID = item.data.clusterNodeId; _cpuXAxis.add( @@ -168,16 +176,14 @@ watch( }, { immediate: true, deep: true }, ); -watch( - () => data.value, - (val) => { - const { time } = val; - if (time && Array.isArray(time) && time.length === 2 && time[0]) { - getCPUEcharts(val); - } - }, - { immediate: true, deep: true }, -); + +watchEffect(() => { + const time = data.value.time + if (time && Array.isArray(time) && time.length === 2 && time[0] && props.serviceId) { + getCPUEcharts(data.value); + } +}) + diff --git a/vite.config.ts b/vite.config.ts index b26c9a8a..4f292d21 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -95,7 +95,7 @@ export default defineConfig(({ mode}) => { // target: 'http://192.168.32.226:8844', // target: 'http://192.168.32.244:8881', target: 'http://120.77.179.54:8844', // 120测试 - // target: 'http://192.168.33.46:8844', // 本地开发环境 + // target: 'http://192.168.33.46:8844', // 本地开发环境 ws: 'ws://120.77.179.54:8844', changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, '')