feat(wip): 複製到剪貼薄

This commit is contained in:
CrescentLeaf
2025-09-25 11:36:03 +08:00
parent a6ee231ad5
commit fdf52c0548
2 changed files with 15 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
import { $ } from 'mdui/jq'
export default function copyToClipboard(text: string) {
if (navigator.clipboard) {
navigator.clipboard.writeText(text)
} else {
const input = $('#copy_to_clipboard_fallback').get(0) as HTMLInputElement
input.value = text
input.select()
input.setSelectionRange(0, 1145141919810)
document.execCommand('copy')
input.clearSelection()
}
}