выфвыфвфывф

This commit is contained in:
dv 2026-05-28 16:38:10 +03:00
parent be51bacc3e
commit 1ff64e4881

View file

@ -48,6 +48,21 @@ import {
dayjs.extend(relativeTime) dayjs.extend(relativeTime)
dayjs.locale('ru') 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 UNGROUPED = '__none__'
const CATEGORY_OPTIONS = [ const CATEGORY_OPTIONS = [
@ -566,7 +581,7 @@ function DevicesList({
const handleCopy = async (snapshotId: number) => { const handleCopy = async (snapshotId: number) => {
try { try {
const content = await fetchSnapshotContent(snapshotId) const content = await fetchSnapshotContent(snapshotId)
await navigator.clipboard.writeText(content) copyToClipboard(content)
message.success('Скопировано в буфер обмена') message.success('Скопировано в буфер обмена')
} catch { } catch {
message.error('Ошибка при копировании') message.error('Ошибка при копировании')
@ -600,9 +615,9 @@ function DevicesList({
} }
} }
const handleViewCopy = async () => { const handleViewCopy = () => {
if (viewContent) { if (viewContent) {
await navigator.clipboard.writeText(viewContent) copyToClipboard(viewContent)
message.success('Скопировано в буфер обмена') message.success('Скопировано в буфер обмена')
} }
} }
@ -691,14 +706,17 @@ function DevicesList({
pagination={false} pagination={false}
/> />
<Modal <Modal
title={viewTitle} title={
open={viewContent !== null} <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
onCancel={() => setViewContent(null)} <span>{viewTitle}</span>
footer={ <Button size="small" icon={<CopyOutlined />} onClick={handleViewCopy}>
<Button icon={<CopyOutlined />} onClick={handleViewCopy}>
Скопировать Скопировать
</Button> </Button>
</div>
} }
open={viewContent !== null}
onCancel={() => setViewContent(null)}
footer={null}
width={800} width={800}
maskClosable maskClosable
destroyOnClose destroyOnClose