Pre Merge pull request !843 from 光帆/N/A

pull/843/MERGE
光帆 2025-12-12 08:47:32 +00:00 committed by Gitee
commit 891c6fcbc1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 23 additions and 3 deletions

View File

@ -187,9 +187,29 @@ const openForm = () => {
/** 复制到剪贴板方法 */ /** 复制到剪贴板方法 */
const copyToClipboard = (text: string) => { const copyToClipboard = (text: string) => {
navigator.clipboard.writeText(text).then(() => { if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard
.writeText(text)
.then(() => {
message.success('复制成功') message.success('复制成功')
}) })
.catch(() => {
message.error('复制失败')
})
} else {
// clipboard
try {
const textarea = document.createElement('textarea')
textarea.value = text
document.body.appendChild(textarea)
textarea.select()
document.execCommand('copy')
document.body.removeChild(textarea)
message.success('复制成功')
} catch (error) {
message.error('复制失败')
}
}
} }
/** 删除按钮操作 */ /** 删除按钮操作 */