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
This commit is contained in:
刘嘉伟 committed 2026-03-26 15:28:21 +08:00
1 parent 01c3a70d2b
commit 3a1ad7ce65
1 file changed
+17 -4
+17 -4
View File
@@ -50,10 +50,23 @@ export function ProxiesView({
const [togglingId, setTogglingId] = useState<string | null>(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({
</Flex>
);
}
const displayText = proxy.remotePort || "-";
if (displayText === "-")
const displayText = proxy.remotePort ? String(proxy.remotePort) : "";
if (!displayText)
return <Text size="2" color="gray">-</Text>;
const copyKey = `${proxy.id}-port`;
const isCopied = copiedId === copyKey;