// 下载blob文件
export const downloadFile = ({ fileData, fileType, fileName }) => {
  const blob = new Blob([fileData], {
    type: fileType
  })
  const link = document.createElement('a')
  link.href = URL.createObjectURL(blob)
  link.download = fileName
  link.style.display = 'none'
  document.body.appendChild(link)
  link.click()
  URL.revokeObjectURL(link.href)
  document.body.removeChild(link)
}

// 通用a链接下载
export const downloadFileByUrl = (url) => {
  const link = document.createElement('a')
  link.href = url
  link.setAttribute('download', '')
  link.style.display = 'none'
  document.body.appendChild(link)
  link.click()
  URL.revokeObjectURL(link.href)
  document.body.removeChild(link)
}

// pdf、doc、docx等文件下载
export const downloadFileData = ({ fileName, fileUrl }) => {
  const link = document.createElement('a')
  link.setAttribute('download', '')
  link.style.display = 'none'
  link.href = fileUrl
  link.download = fileName
  document.body.appendChild(link)
  link.click(); 
  // URL.revokeObjectURL(link.href)
  document.body.removeChild(link)
}