выфвыфвфывф

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.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}
/>
<Modal
title={viewTitle}
title={
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<span>{viewTitle}</span>
<Button size="small" icon={<CopyOutlined />} onClick={handleViewCopy}>
Скопировать
</Button>
</div>
}
open={viewContent !== null}
onCancel={() => setViewContent(null)}
footer={
<Button icon={<CopyOutlined />} onClick={handleViewCopy}>
Скопировать
</Button>
}
footer={null}
width={800}
maskClosable
destroyOnClose