From a05a886d3da624bd070f9b984025e27dfa82bdb6 Mon Sep 17 00:00:00 2001 From: ji ruo <79234113+RuoJi6@users.noreply.github.com> Date: Mon, 9 Nov 2026 16:17:03 +0800 Subject: [PATCH] fix: support traffic ID copying over HTTP --- web/src/components/traffic-history.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/web/src/components/traffic-history.tsx b/web/src/components/traffic-history.tsx index a1752bd..b43e745 100644 --- a/web/src/components/traffic-history.tsx +++ b/web/src/components/traffic-history.tsx @@ -48,7 +48,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip import { api } from "@/lib/api"; import { useStoredSortPreference } from "@/lib/sort-preference"; import type { TrafficDetail, TrafficExchange, TrafficHost, TrafficResp } from "@/lib/types"; -import { cn } from "@/lib/utils"; +import { cn, copyText } from "@/lib/utils"; function fmtTime(ts: string) { return new Date(ts).toLocaleString("zh-CN", { @@ -92,10 +92,9 @@ function TrafficID({ id }: { id: string }) { aria-label={`复制流量 ID ${id}`} onClick={async (event) => { event.stopPropagation(); - try { - await navigator.clipboard.writeText(id); + if (await copyText(id)) { toast.success("已复制流量 ID"); - } catch { + } else { toast.error("复制失败,请手动选择流量 ID"); } }}