navigator.permissions.query({ name: "clipboard-read" }).then(result => {
// If permission to read the clipboard is granted or if the user will
// be prompted to allow it, we proceed.
if (result.state == "granted" || result.state == "prompt") {
navigator.clipboard.read().then(data => {
for (const clipboardItem of data) {
let flag = 0;
for (const type of clipboardItem.types) {
clipboardItem.getType(type).then(blob => {
// we can now use blob here
if (blob.type.includes('image')) {
debugger
let name = Math.ceil(Math.random() * 100000).toString();
let file = new window.File([blob], name+'.png', { type: blob.type })
uploadFile(file);
flag++;
}
});
}
if (flag == 0) {
layer.msg('未获取到图片', { icon: 5 })
}
}
});
}
});