@@ -12,7 +12,7 @@ import { BasicResponse, RESPONSE_TIPS, STATUS_CODE } from '@common/const/const'
1212import { App } from 'antd'
1313import ServiceAreaChart from './charts/ServiceAreaChart'
1414import RankingList from './rankingList/RankingList'
15- import { getTime } from '@dashboard/utils/dashboard'
15+ import { abbreviateFloat , formatBytes , formatDuration , formatNumberWithUnit , getTime } from '@dashboard/utils/dashboard'
1616import { setBarChartInfoData } from './utils'
1717import { useGlobalContext } from '@common/contexts/GlobalStateContext'
1818
@@ -78,7 +78,11 @@ const ServiceOverview = ({ serviceType }: { serviceType: 'aiService' | 'restServ
7878 'request_4xx_total' ,
7979 'request_5xx_total' ,
8080 'input_token_total' ,
81- 'output_token_total'
81+ 'output_token_total' ,
82+ 'max_token_per_subscriber' ,
83+ 'min_token_per_subscriber' ,
84+ 'max_request_per_subscriber' ,
85+ 'min_request_per_subscriber'
8286 ]
8387 } ) . then ( ( response ) => {
8488 const { code, data, msg } = response
@@ -114,24 +118,24 @@ const ServiceOverview = ({ serviceType }: { serviceType: 'aiService' | 'restServ
114118 ...setBarChartInfoData ( {
115119 title : $t ( '请求次数' ) ,
116120 data : serviceOverview . requestOverview ,
117- value : serviceOverview . requestTotal ,
121+ value : formatNumberWithUnit ( serviceOverview . requestTotal ) ,
118122 date : serviceOverview . date
119123 } ) ,
120- request2xxTotal : serviceOverview . request2xxTotal ,
121- request4xxTotal : serviceOverview . request4xxTotal ,
122- request5xxTotal : serviceOverview . request5xxTotal
124+ request2xxTotal : formatNumberWithUnit ( serviceOverview . request2xxTotal ) ,
125+ request4xxTotal : formatNumberWithUnit ( serviceOverview . request4xxTotal ) ,
126+ request5xxTotal : formatNumberWithUnit ( serviceOverview . request5xxTotal )
123127 } ,
124128 // 流量消耗总数
125129 {
126130 ...setBarChartInfoData ( {
127131 title : $t ( '网络流量' ) ,
128132 data : serviceOverview . trafficOverview ,
129- value : serviceOverview . trafficTotal ,
133+ value : formatBytes ( serviceOverview . trafficTotal ) ,
130134 date : serviceOverview . date
131135 } ) ,
132- traffic2xxTotal : serviceOverview . traffic2xxTotal ,
133- traffic4xxTotal : serviceOverview . traffic4xxTotal ,
134- traffic5xxTotal : serviceOverview . traffic5xxTotal
136+ traffic2xxTotal : formatBytes ( serviceOverview . traffic2xxTotal ) ,
137+ traffic4xxTotal : formatBytes ( serviceOverview . traffic4xxTotal ) ,
138+ traffic5xxTotal : formatBytes ( serviceOverview . traffic5xxTotal )
135139 }
136140 ] )
137141 // 设置平均值数据
@@ -140,29 +144,36 @@ const ServiceOverview = ({ serviceType }: { serviceType: 'aiService' | 'restServ
140144 {
141145 title : $t ( '平均响应时间' ) ,
142146 data : serviceOverview . avgResponseTimeOverview ,
143- value : serviceOverview . avgResponseTime ,
147+ value : formatDuration ( serviceOverview . avgResponseTime ) ,
148+ originValue : serviceOverview . avgResponseTime ,
144149 date : serviceOverview . date ,
145- max : serviceOverview . maxResponseTime ,
146- min : serviceOverview . minResponseTime ,
150+ max : formatDuration ( serviceOverview . maxResponseTime ) ,
151+ min : formatDuration ( serviceOverview . minResponseTime ) ,
147152 type : 'area' ,
148153 showXAxis : false
149154 } ,
150155 // 平均请求
151- setBarChartInfoData ( {
152- title : $t ( '平均每消费者的请求次数' ) ,
153- data : serviceOverview . avgRequestPerSubscriberOverview ,
154- value : serviceOverview . avgRequestPerSubscriber ,
155- date : serviceOverview . date ,
156- showXAxis : false
157- } ) ,
156+ {
157+ ...setBarChartInfoData ( {
158+ title : $t ( '平均每消费者的请求次数' ) ,
159+ data : serviceOverview . avgRequestPerSubscriberOverview ,
160+ date : serviceOverview . date ,
161+ showXAxis : false
162+ } ) ,
163+ max : abbreviateFloat ( serviceOverview . maxRequestPerSubscriber ) ,
164+ min : abbreviateFloat ( serviceOverview . minRequestPerSubscriber )
165+ } ,
158166 // 平均流量消耗
159- setBarChartInfoData ( {
160- title : $t ( '平均每消费者的网络流量' ) ,
161- data : serviceOverview . avgTrafficPerSubscriberOverview ,
162- value : serviceOverview . avgTrafficPerSubscriber ,
163- date : serviceOverview . date ,
164- showXAxis : false
165- } )
167+ {
168+ ...setBarChartInfoData ( {
169+ title : $t ( '平均每消费者的网络流量' ) ,
170+ data : serviceOverview . avgTrafficPerSubscriberOverview ,
171+ date : serviceOverview . date ,
172+ showXAxis : false
173+ } ) ,
174+ max : formatBytes ( serviceOverview . maxTrafficPerSubscriber ) ,
175+ min : formatBytes ( serviceOverview . minTrafficPerSubscriber )
176+ }
166177 ] )
167178 }
168179
@@ -186,12 +197,12 @@ const ServiceOverview = ({ serviceType }: { serviceType: 'aiService' | 'restServ
186197 ...setBarChartInfoData ( {
187198 title : $t ( '请求次数' ) ,
188199 data : serviceOverview . requestOverview ,
189- value : serviceOverview . requestTotal ,
200+ value : formatNumberWithUnit ( serviceOverview . requestTotal ) ,
190201 date : serviceOverview . date
191202 } ) ,
192- request2xxTotal : serviceOverview . request2xxTotal ,
193- request4xxTotal : serviceOverview . request4xxTotal ,
194- request5xxTotal : serviceOverview . request5xxTotal
203+ request2xxTotal : formatNumberWithUnit ( serviceOverview . request2xxTotal ) ,
204+ request4xxTotal : formatNumberWithUnit ( serviceOverview . request4xxTotal ) ,
205+ request5xxTotal : formatNumberWithUnit ( serviceOverview . request5xxTotal )
195206 } ,
196207 // token 消耗总数
197208 {
@@ -201,11 +212,11 @@ const ServiceOverview = ({ serviceType }: { serviceType: 'aiService' | 'restServ
201212 inputToken : item . inputToken ,
202213 outputToken : item . outputToken
203214 } ) ) ,
204- value : serviceOverview . tokenTotal ,
215+ value : formatNumberWithUnit ( serviceOverview . tokenTotal ) ,
205216 date : serviceOverview . date
206217 } ) ,
207- inputTokenTotal : serviceOverview . inputTokenTotal ,
208- outputTokenTotal : serviceOverview . outputTokenTotal
218+ inputTokenTotal : formatNumberWithUnit ( serviceOverview . inputTokenTotal ) ,
219+ outputTokenTotal : formatNumberWithUnit ( serviceOverview . outputTokenTotal )
209220 }
210221 ] )
211222 // 设置平均值数据
@@ -214,29 +225,38 @@ const ServiceOverview = ({ serviceType }: { serviceType: 'aiService' | 'restServ
214225 {
215226 title : $t ( '平均 Token 消耗' ) ,
216227 data : serviceOverview . avgTokenOverview ,
217- value : serviceOverview . avgToken ,
228+ value : formatNumberWithUnit ( serviceOverview . avgToken ) + ' Token/s' ,
229+ originValue : serviceOverview . avgToken ,
218230 date : serviceOverview . date ,
219- min : serviceOverview . minToken ,
220- max : serviceOverview . maxToken ,
231+ min : formatNumberWithUnit ( serviceOverview . minToken ) + ' Token/s' ,
232+ max : formatNumberWithUnit ( serviceOverview . maxToken ) + ' Token/s' ,
221233 type : 'area'
222234 } ,
223- // 平均请求
224- setBarChartInfoData ( {
225- title : $t ( '平均每消费者的请求次数' ) ,
226- data : serviceOverview . avgRequestPerSubscriberOverview ,
227- value : serviceOverview . avgRequestPerSubscriber ,
228- date : serviceOverview . date
229- } ) ,
235+ {
236+ // 平均请求
237+ ...setBarChartInfoData ( {
238+ title : $t ( '平均每消费者的请求次数' ) ,
239+ data : serviceOverview . avgRequestPerSubscriberOverview ,
240+ date : serviceOverview . date
241+ } ) ,
242+ max : abbreviateFloat ( serviceOverview . maxRequestPerSubscriber ) ,
243+ min : abbreviateFloat ( serviceOverview . minRequestPerSubscriber )
244+ } ,
230245 // 评价 token 消耗
231- setBarChartInfoData ( {
232- title : $t ( '平均每消费者的 Token 消耗' ) ,
233- data : serviceOverview . avgTokenPerSubscriberOverview . map ( ( item : { inputToken : number ; outputToken : number } ) => ( {
234- inputToken : item . inputToken ,
235- outputToken : item . outputToken
236- } ) ) ,
237- value : serviceOverview . avgTokenPerSubscriber ,
238- date : serviceOverview . date
239- } )
246+ {
247+ ...setBarChartInfoData ( {
248+ title : $t ( '平均每消费者的 Token 消耗' ) ,
249+ data : serviceOverview . avgTokenPerSubscriberOverview . map (
250+ ( item : { inputToken : number ; outputToken : number } ) => ( {
251+ inputToken : item . inputToken ,
252+ outputToken : item . outputToken
253+ } )
254+ ) ,
255+ date : serviceOverview . date
256+ } ) ,
257+ max : abbreviateFloat ( serviceOverview . maxTokenPerSubscriber ) ,
258+ min : abbreviateFloat ( serviceOverview . minTokenPerSubscriber )
259+ }
240260 ] )
241261 }
242262
@@ -268,7 +288,11 @@ const ServiceOverview = ({ serviceType }: { serviceType: 'aiService' | 'restServ
268288 'request_5xx_total' ,
269289 'traffic_2xx_total' ,
270290 'traffic_4xx_total' ,
271- 'traffic_5xx_total'
291+ 'traffic_5xx_total' ,
292+ 'max_request_per_subscriber' ,
293+ 'min_request_per_subscriber' ,
294+ 'max_traffic_per_subscriber' ,
295+ 'min_traffic_per_subscriber'
272296 ]
273297 } ) . then ( ( response ) => {
274298 const { code, data, msg } = response
@@ -354,7 +378,13 @@ const ServiceOverview = ({ serviceType }: { serviceType: 'aiService' | 'restServ
354378 body : 'py-[15px] px-[0px]'
355379 } }
356380 >
357- < ServiceBarChar showLegendIndicator = { true } key = { index } height = { 400 } dataInfo = { item } customClassNames = "flex-1" > </ ServiceBarChar >
381+ < ServiceBarChar
382+ showLegendIndicator = { true }
383+ key = { index }
384+ height = { 400 }
385+ dataInfo = { item }
386+ customClassNames = "flex-1"
387+ > </ ServiceBarChar >
358388 </ Card >
359389 ) ) }
360390 </ div >
@@ -378,7 +408,13 @@ const ServiceOverview = ({ serviceType }: { serviceType: 'aiService' | 'restServ
378408 > </ ServiceAreaChart >
379409 </ >
380410 ) : (
381- < ServiceBarChar key = { index } height = { 270 } dataInfo = { item } showAvgLine = { true } customClassNames = "flex-1" > </ ServiceBarChar >
411+ < ServiceBarChar
412+ key = { index }
413+ height = { 270 }
414+ dataInfo = { item }
415+ hideIndicatorValue = { true }
416+ customClassNames = "flex-1"
417+ > </ ServiceBarChar >
382418 ) }
383419 </ Card >
384420 ) ) }
0 commit comments