@@ -50,6 +50,9 @@ const defaultFilters: FilterDraft = {
5050 limit : 100 ,
5151} ;
5252const PAGE_SIZE_OPTIONS = [ 20 , 50 , 100 , 200 , 500 , 1000 , 2000 ] as const ;
53+ const REQUEST_LOGS_FORWARD_BADGE_CLASS = "request-logs-proxy-badge-forward" ;
54+ const REQUEST_LOGS_REVERSE_BADGE_CLASS = "request-logs-proxy-badge-reverse" ;
55+ const REQUEST_LOGS_SOCKS_BADGE_CLASS = "request-logs-proxy-badge-socks" ;
5356
5457const PAYLOAD_TABS = [ "request" , "response" ] as const ;
5558type PayloadTab = ( typeof PAYLOAD_TABS ) [ number ] ;
@@ -287,6 +290,19 @@ function proxyTypeLabel(proxyType: number): string {
287290 return String ( proxyType ) ;
288291}
289292
293+ function proxyTypeBadgeClassName ( proxyType : number ) : string | null {
294+ if ( proxyType === 1 ) {
295+ return REQUEST_LOGS_FORWARD_BADGE_CLASS ;
296+ }
297+ if ( proxyType === 2 ) {
298+ return REQUEST_LOGS_REVERSE_BADGE_CLASS ;
299+ }
300+ if ( proxyType === 3 ) {
301+ return REQUEST_LOGS_SOCKS_BADGE_CLASS ;
302+ }
303+ return null ;
304+ }
305+
290306function dateLocale ( ) : string {
291307 return isEnglishLocale ( getCurrentLocale ( ) ) ? "en-US" : "zh-CN" ;
292308}
@@ -512,6 +528,23 @@ export function RequestLogsPage() {
512528 } , [ payloadQuery . data , payloadTab , t ] ) ;
513529
514530 const hasMore = Boolean ( logsQuery . data ?. has_more && logsQuery . data ?. next_cursor ) ;
531+ const renderProxyTypeBadge = ( proxyType : number , context : "table" | "drawer" = "table" ) => {
532+ const className = proxyTypeBadgeClassName ( proxyType ) ;
533+ if ( ! className ) {
534+ return t ( proxyTypeLabel ( proxyType ) ) ;
535+ }
536+
537+ let label = "" ;
538+ if ( proxyType === 1 ) {
539+ label = context === "drawer" ? t ( "HTTP" ) : t ( "正向" ) ;
540+ } else if ( proxyType === 2 ) {
541+ label = t ( "反向" ) ;
542+ } else {
543+ label = t ( "SOCKS5" ) ;
544+ }
545+
546+ return < Badge className = { className } > { label } </ Badge > ;
547+ } ;
515548
516549 const col = useMemo ( ( ) => createColumnHelper < RequestLogItem > ( ) , [ ] ) ;
517550
@@ -531,13 +564,7 @@ export function RequestLogsPage() {
531564 } ) ,
532565 col . accessor ( "proxy_type" , {
533566 header : t ( "代理" ) ,
534- cell : ( info ) => {
535- const val = info . getValue ( ) ;
536- if ( val === 1 ) return < Badge variant = "info" > { t ( "正向" ) } </ Badge > ;
537- if ( val === 2 ) return < Badge variant = "accent" > { t ( "反向" ) } </ Badge > ;
538- if ( val === 3 ) return < Badge variant = "warning" > { t ( "SOCKS5" ) } </ Badge > ;
539- return < Badge variant = "neutral" > { val } </ Badge > ;
540- } ,
567+ cell : ( info ) => renderProxyTypeBadge ( info . getValue ( ) ) ,
541568 } ) ,
542569 col . display ( {
543570 id : "platform_account" ,
@@ -894,17 +921,7 @@ export function RequestLogsPage() {
894921 </ div >
895922 < div >
896923 < span > { t ( "代理类型" ) } </ span >
897- < p >
898- { detailLog . proxy_type === 1 ? (
899- < Badge variant = "info" > { t ( "HTTP" ) } </ Badge >
900- ) : detailLog . proxy_type === 2 ? (
901- < Badge variant = "accent" > { t ( "反向" ) } </ Badge >
902- ) : detailLog . proxy_type === 3 ? (
903- < Badge variant = "warning" > { t ( "SOCKS5" ) } </ Badge >
904- ) : (
905- t ( proxyTypeLabel ( detailLog . proxy_type ) )
906- ) }
907- </ p >
924+ < p > { renderProxyTypeBadge ( detailLog . proxy_type , "drawer" ) } </ p >
908925 </ div >
909926 < div >
910927 < span > { t ( "HTTP" ) } </ span >
0 commit comments