выфвыфвфывф
This commit is contained in:
parent
be51bacc3e
commit
1ff64e4881
1 changed files with 27 additions and 9 deletions
|
|
@ -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={
|
||||||
|
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||||
|
<span>{viewTitle}</span>
|
||||||
|
<Button size="small" icon={<CopyOutlined />} onClick={handleViewCopy}>
|
||||||
|
Скопировать
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
open={viewContent !== null}
|
open={viewContent !== null}
|
||||||
onCancel={() => setViewContent(null)}
|
onCancel={() => setViewContent(null)}
|
||||||
footer={
|
footer={null}
|
||||||
<Button icon={<CopyOutlined />} onClick={handleViewCopy}>
|
|
||||||
Скопировать
|
|
||||||
</Button>
|
|
||||||
}
|
|
||||||
width={800}
|
width={800}
|
||||||
maskClosable
|
maskClosable
|
||||||
destroyOnClose
|
destroyOnClose
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue