mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-06-08 17:20:38 +08:00
fix bug
This commit is contained in:
19
src/@core/utils/navigator.ts
Normal file
19
src/@core/utils/navigator.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
// 请求和获取剪切板内容
|
||||
export async function getClipboardContent() {
|
||||
return await navigator.clipboard.readText()
|
||||
}
|
||||
|
||||
// 将内容复制到剪切板,兼容非安全域场景
|
||||
export async function copyToClipboard(content: string) {
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
await navigator.clipboard.writeText(content)
|
||||
}
|
||||
else {
|
||||
const input = document.createElement('input')
|
||||
input.value = content
|
||||
document.body.appendChild(input)
|
||||
input.select()
|
||||
document.execCommand('copy')
|
||||
document.body.removeChild(input)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user