fixbug: 🐛 修改服务监控bug

This commit is contained in:
bunny 2024-10-25 17:00:13 +08:00
parent e873d138dd
commit f37cb642be
2 changed files with 16 additions and 12 deletions

View File

@ -59,18 +59,20 @@ const option = reactive<UtilsEChartsOption>({
/** 初始化数据 */
const onSearch = async () => {
//
const result = await fetchSystemCPU();
const value = result.measurements[0].value ?? 0;
// 10
if (seriesData.value.length > 5) {
seriesData.value = seriesData.value.slice(-5);
xSeriesData.value = xSeriesData.value.slice(-5);
}
seriesData.value.push(value * 100);
xSeriesData.value.push(dayjs().format('mm:ss'));
//
const result = await fetchSystemCPU();
const measurement = result.measurements[0];
if (measurement) {
const value = measurement.value;
seriesData.value.push(value * 100);
xSeriesData.value.push(dayjs().format('mm:ss'));
}
myChart.value.setOption({
xAxis: { data: xSeriesData.value },

View File

@ -58,18 +58,20 @@ const option = reactive<UtilsEChartsOption>({
/** 初始化数据 */
const onSearch = async () => {
//
const result = await fetchSystemProcessCPU();
const value = result.measurements[0].value;
// 10
if (seriesData.value.length > 5) {
seriesData.value = seriesData.value.slice(-5);
xSeriesData.value = xSeriesData.value.slice(-5);
}
seriesData.value.push(value * 100);
xSeriesData.value.push(dayjs().format('mm:ss'));
//
const result = await fetchSystemProcessCPU();
const measurement = result.measurements[0];
if (measurement) {
const value = measurement.value;
seriesData.value.push(value * 100);
xSeriesData.value.push(dayjs().format('mm:ss'));
}
myChart.value.setOption({
xAxis: { data: xSeriesData.value },