fix 规则导入

This commit is contained in:
jxxghp
2023-11-30 15:18:10 +08:00
parent 061a3f393a
commit 37a0e83124
5 changed files with 134 additions and 65 deletions
+8 -14
View File
@@ -1,13 +1,10 @@
// 请求和获取剪板内容
// 请求和获取剪板内容
export async function getClipboardContent() {
try {
if (navigator.clipboard && window.isSecureContext) {
return await navigator.clipboard.readText()
}
catch (error) {
console.error('Unable to read clipboard using navigator.clipboard:', error)
// Fallback for older browsers or non-secure context
const input = document.createElement('input')
else {
const input = document.createElement('textarea')
document.body.appendChild(input)
input.select()
document.execCommand('paste')
@@ -17,16 +14,13 @@ export async function getClipboardContent() {
}
}
// 将内容复制到剪板,兼容非安全域场景
// 将内容复制到剪板,兼容非安全域场景
export async function copyToClipboard(content: string) {
try {
if (navigator.clipboard && window.isSecureContext) {
await navigator.clipboard.writeText(content)
}
catch (error) {
console.error('Unable to write to clipboard using navigator.clipboard:', error)
// Fallback for older browsers or non-secure context
const input = document.createElement('input')
else {
const input = document.createElement('textarea')
input.value = content
document.body.appendChild(input)
input.select()