diff --git a/frontend/src/pages/SnapshotDashboard.tsx b/frontend/src/pages/SnapshotDashboard.tsx index 7e373b7..b98e1f7 100644 --- a/frontend/src/pages/SnapshotDashboard.tsx +++ b/frontend/src/pages/SnapshotDashboard.tsx @@ -48,6 +48,21 @@ import { dayjs.extend(relativeTime) dayjs.locale('ru') +function copyToClipboard(text: string) { + if (navigator.clipboard && window.isSecureContext) { + navigator.clipboard.writeText(text) + } else { + const textarea = document.createElement('textarea') + textarea.value = text + textarea.style.position = 'fixed' + textarea.style.left = '-9999px' + document.body.appendChild(textarea) + textarea.select() + document.execCommand('copy') + document.body.removeChild(textarea) + } +} + const UNGROUPED = '__none__' const CATEGORY_OPTIONS = [ @@ -566,7 +581,7 @@ function DevicesList({ const handleCopy = async (snapshotId: number) => { try { const content = await fetchSnapshotContent(snapshotId) - await navigator.clipboard.writeText(content) + copyToClipboard(content) message.success('Скопировано в буфер обмена') } catch { message.error('Ошибка при копировании') @@ -600,9 +615,9 @@ function DevicesList({ } } - const handleViewCopy = async () => { + const handleViewCopy = () => { if (viewContent) { - await navigator.clipboard.writeText(viewContent) + copyToClipboard(viewContent) message.success('Скопировано в буфер обмена') } } @@ -691,14 +706,17 @@ function DevicesList({ pagination={false} /> + {viewTitle} + + + } open={viewContent !== null} onCancel={() => setViewContent(null)} - footer={ - - } + footer={null} width={800} maskClosable destroyOnClose