electron 读取剪贴板文件

// 从资源管理器中复制文件到剪贴板
let filePath;
if (remote.process.platform == 'win32') { // windows
  // 只读取一个文件路径
  const rawFilePath = clipboard.readBuffer('FileNameW').toString('ucs2');
  filePath = rawFilePath.replace(new RegExp(String.fromCharCode(0), 'g'), '');
} else if (remote.process.platform == 'darwin') { // mac
  filePath = clipboard.read('public.file-url').replace('file://', '');
}

// 截图或网页或微信等内复制图片
let nativeImage = clipboard.readImage();
if (!nativeImage.isEmpty()) {
  let base64 = nativeImage.toDataURL();
  // todo
  e.preventDefault();
  return;
}

扫描二维码,在手机上阅读!