Feat:减少一次在firefox浏览器上粘贴剪贴板内容时的提示

This commit is contained in:
wanglin2
2024-08-22 22:32:28 +08:00
parent 9ef90a7057
commit b8765bdd99

View File

@@ -1080,14 +1080,15 @@ export const getDataFromClipboard = async () => {
let text = null
let img = null
if (navigator.clipboard) {
text = await navigator.clipboard.readText()
const items = await navigator.clipboard.read()
if (items && items.length > 0) {
for (const clipboardItem of items) {
for (const type of clipboardItem.types) {
if (/^image\//.test(type)) {
img = await clipboardItem.getType(type)
break
} else if (type === 'text/plain') {
const blob = await clipboardItem.getType(type)
text = await blob.text()
}
}
}