Skip to content

Commit 33c256f

Browse files
committed
feat: add toggle to hide route values in records table
1 parent 0c938d6 commit 33c256f

1 file changed

Lines changed: 34 additions & 4 deletions

File tree

app/records/page.tsx

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ export default function RecordsPage() {
156156

157157
const [sortField, setSortField] = useState<SortField>("occurredAt");
158158
const [sortOrder, setSortOrder] = useState<SortOrder>("desc");
159+
const [hideRouteValue, setHideRouteValue] = useState(() => {
160+
if (typeof window === "undefined") return false;
161+
return window.localStorage.getItem("records-hide-route") === "1";
162+
});
159163

160164
const sentinelRef = useRef<HTMLDivElement | null>(null);
161165
const loadingRef = useRef(false);
@@ -356,14 +360,14 @@ export default function RecordsPage() {
356360
const filterSummary = useMemo(() => {
357361
const parts: string[] = [];
358362
if (appliedModel) parts.push(`模型: ${appliedModel}`);
359-
if (appliedRoute) parts.push(`密钥: ${appliedRoute}`);
363+
if (appliedRoute) parts.push(`密钥: ${hideRouteValue ? "-" : appliedRoute}`);
360364
if (appliedStart || appliedEnd) {
361365
const startLabel = appliedStart ? formatDateTimeDisplay(appliedStart) : "-";
362366
const endLabel = appliedEnd ? formatDateTimeDisplay(appliedEnd) : "-";
363367
parts.push(`时间: ${startLabel} ~ ${endLabel}`);
364368
}
365369
return parts.length ? parts.join(" / ") : "暂无筛选";
366-
}, [appliedModel, appliedRoute, appliedStart, appliedEnd]);
370+
}, [appliedModel, appliedRoute, appliedStart, appliedEnd, hideRouteValue]);
367371

368372
const rangeLabel = useMemo(() => {
369373
if (!startInput && !endInput) return "选择时间范围";
@@ -422,6 +426,11 @@ export default function RecordsPage() {
422426
return () => document.removeEventListener("mousedown", handleClickOutside);
423427
}, [rangePickerOpen]);
424428

429+
useEffect(() => {
430+
if (typeof window === "undefined") return;
431+
window.localStorage.setItem("records-hide-route", hideRouteValue ? "1" : "0");
432+
}, [hideRouteValue]);
433+
425434
return (
426435
<main className="min-h-screen bg-slate-900 px-6 py-8 text-slate-100">
427436
<header className="flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
@@ -607,6 +616,27 @@ export default function RecordsPage() {
607616
重置
608617
</button>
609618
</div>
619+
620+
<div className="ml-auto flex items-center gap-3">
621+
<label className="inline-flex items-center gap-2 text-sm text-slate-300">
622+
<span>隐藏密钥</span>
623+
<button
624+
type="button"
625+
role="switch"
626+
aria-checked={hideRouteValue}
627+
onClick={() => setHideRouteValue((prev) => !prev)}
628+
className={`relative inline-flex h-5 w-9 items-center rounded-full transition ${
629+
hideRouteValue ? "bg-indigo-500" : "bg-slate-600"
630+
}`}
631+
>
632+
<span
633+
className={`inline-block h-4 w-4 transform rounded-full bg-white transition ${
634+
hideRouteValue ? "translate-x-4" : "translate-x-0.5"
635+
}`}
636+
/>
637+
</button>
638+
</label>
639+
</div>
610640
</div>
611641
<p className="mt-3 text-xs text-slate-500">当前筛选:{filterSummary}</p>
612642
</section>
@@ -714,8 +744,8 @@ export default function RecordsPage() {
714744
</div>
715745
</td>
716746
<td className="px-3 py-3 first:rounded-l-lg last:rounded-r-lg">
717-
<div className="max-w-[200px] truncate text-slate-300" title={row.route}>
718-
{row.route}
747+
<div className="max-w-[200px] truncate text-slate-300" title={hideRouteValue ? "-" : row.route}>
748+
{hideRouteValue ? "-" : row.route}
719749
</div>
720750
</td>
721751
<td className="px-3 py-3 first:rounded-l-lg last:rounded-r-lg">

0 commit comments

Comments
 (0)