From 3a1ad7ce65a3364c03bec1f3ae0b7d04bba27053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=98=89=E4=BC=9F?= <8473136@qq.com> Date: Thu, 26 Mar 2026 15:28:21 +0800 Subject: [PATCH] feat(proxies): enhance clipboard compatibility and remote port display - Improve clipboard copy functionality with fallback for older browsers - Change remote port display logic to show empty string instead of "-" for missing values - Maintain consistent copy feedback behavior across all browser environments --- site/src/pages/Proxies/ProxiesPage.view.tsx | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/site/src/pages/Proxies/ProxiesPage.view.tsx b/site/src/pages/Proxies/ProxiesPage.view.tsx index ca0f284..ebf7900 100644 --- a/site/src/pages/Proxies/ProxiesPage.view.tsx +++ b/site/src/pages/Proxies/ProxiesPage.view.tsx @@ -50,10 +50,23 @@ export function ProxiesView({ const [togglingId, setTogglingId] = useState(null); const handleCopy = (text: string, id: string) => { - navigator.clipboard.writeText(text).then(() => { + const done = () => { setCopiedId(id); setTimeout(() => setCopiedId(null), 1500); - }); + }; + if (navigator.clipboard) { + navigator.clipboard.writeText(text).then(done); + } else { + const el = document.createElement("textarea"); + el.value = text; + el.style.position = "fixed"; + el.style.opacity = "0"; + document.body.appendChild(el); + el.select(); + document.execCommand("copy"); + document.body.removeChild(el); + done(); + } }; useEffect(() => { @@ -301,8 +314,8 @@ export function ProxiesView({ ); } - const displayText = proxy.remotePort || "-"; - if (displayText === "-") + const displayText = proxy.remotePort ? String(proxy.remotePort) : ""; + if (!displayText) return -; const copyKey = `${proxy.id}-port`; const isCopied = copiedId === copyKey;