@@ -5,66 +5,68 @@ definePageMeta({
55
66const monitorData = useState <MonitorInfo []>(' monitorData' )
77
8+ function getColor(value : number ): string {
9+ if (value < 200 ) return ' #52c41a'
10+ if (value < 500 ) return ' #faad14'
11+ return ' #f5222d'
12+ }
13+
814function formatTime(timestamp : number ): string {
915 return new Date (timestamp ).toLocaleTimeString ()
1016}
1117
12- function getChartOption(item : MonitorInfo ) {
18+ function getChartOption(item : MonitorInfo ): ECOption {
1319 const times = item .data .map (data => formatTime (data .time ))
14- const delays = item .data .map (data => data .delay )
20+ const delays = item .data .map (data => ({
21+ value: data .delay ,
22+ itemStyle: {
23+ color: getColor (data .delay ),
24+ },
25+ }))
1526
1627 return {
1728 tooltip: {
1829 trigger: ' axis' ,
1930 },
31+ grid: {
32+ left: 0 ,
33+ right: 16 ,
34+ top: 8 ,
35+ bottom: 8 ,
36+ containLabel: true ,
37+ },
2038 xAxis: {
2139 type: ' category' ,
2240 data: times ,
23- axisLabel: {
24- rotate: 45 ,
25- formatter : (value : string ) => value .slice (0 , 8 ),
26- },
2741 },
2842 yAxis: {
2943 type: ' value' ,
30- name: ' 延迟 (ms) ' ,
44+ show: false ,
3145 },
3246 series: [
3347 {
3448 name: ' 延迟' ,
35- type: ' line' ,
36- smooth: true ,
49+ type: ' bar' ,
3750 data: delays ,
38- lineStyle: {
39- width: 2 ,
40- color: ' #5470c6' ,
41- },
42- areaStyle: {
43- color: ' rgba(84, 112, 198, 0.2)' ,
44- },
51+ barWidth: ' 70%' ,
4552 },
4653 ],
4754 }
4855}
4956 </script >
5057
5158<template >
52- <ACard class =" w-full p -4" >
59+ <div class =" flex w-full flex-col gap -4" >
5360 <template v-for =" item in monitorData " :key =" item .host " >
54- <div
55- class =" mb-6 flex flex-col items-start rounded-lg bg-gray-50 p-4 shadow lg:flex-row"
56- >
57- <div class =" mb-4 w-full lg:mb-0 lg:w-1/4 lg:pr-4" >
58- <h2 class =" text-lg font-semibold text-gray-700" >{{ item.host }}</h2 >
59- <p class =" text-sm text-gray-500" >监控点数:{{ item.data.length }}</p >
60- </div >
61- <div class =" w-full lg:w-3/4" >
62- <VChart
63- :option =" getChartOption(item)"
64- style =" width : 100% ; height : 200px "
65- />
66- </div >
67- </div >
61+ <ACard :title =" item.host" >
62+ <VChart :option =" getChartOption(item)" class =" h-24 w-full" />
63+ </ACard >
6864 </template >
69- </ACard >
65+ </div >
7066</template >
67+
68+ <style scoped>
69+ :deep(.arco-card-size-medium .arco-card-body ) {
70+ padding : 0px !important ;
71+ }
72+ </style >
0 commit comments