public async getClipboardContents() {
try {
const clipboardItems = await (navigator as any).clipboard.read();
if (clipboardItems[0].types[0].indexOf('image') > -1) {
const b = await clipboardItems[0].getType(clipboardItems[0].types[0]);
const files = new window.File([b], `${Math.floor(Math.random() * 2147483648).toString(36)}.png`, {type: clipboardItems[0].types[0]});
// const info = await uploadByChunk({file:files} , (res:any) => {})
// const param = {id: this.previewItem.id, coverUrl: info?.data.downloadUrl}
// this.$emit('setcoverImg', param)
// this.previewShow = false
const clear = await (navigator as any).clipboard.writeText('清空素材库截图');
} else {
this.$message({message: '尚未进行截图!', type: 'error', customClass: 'msgZindex'});
}
} catch (err) {
this.$message({message: '获取截图失败!', type: 'error', customClass: 'msgZindex'});
}
}
读取剪切板截图
最新推荐文章于 2024-05-07 17:08:10 发布