Skip to content

Commit 24e6526

Browse files
committed
Refine request log proxy badge styles
1 parent 9a3d1e2 commit 24e6526

2 files changed

Lines changed: 51 additions & 19 deletions

File tree

webui/src/features/requestLogs/RequestLogsPage.tsx

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ const defaultFilters: FilterDraft = {
5050
limit: 100,
5151
};
5252
const 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

5457
const PAYLOAD_TABS = ["request", "response"] as const;
5558
type 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+
290306
function 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>

webui/src/styles/theme.css

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,21 @@ a {
595595
background: #e6e9ef;
596596
}
597597

598+
.request-logs-proxy-badge-forward {
599+
color: #1a5fb4;
600+
background: rgba(20, 112, 255, 0.12);
601+
}
602+
603+
.request-logs-proxy-badge-reverse {
604+
color: #7b3fa0;
605+
background: rgba(145, 65, 200, 0.12);
606+
}
607+
608+
.request-logs-proxy-badge-socks {
609+
color: #eff6ff;
610+
background: #3f6cba;
611+
}
612+
598613
.callout {
599614
display: inline-flex;
600615
width: 100%;
@@ -1715,7 +1730,7 @@ a {
17151730
padding: 10px;
17161731
}
17171732

1718-
.stats-grid span {
1733+
.stats-grid > div > span {
17191734
display: inline-flex;
17201735
font-size: 12px;
17211736
color: var(--text-muted);

0 commit comments

Comments
 (0)