// import  getBrowser from './getBrowser';
// import  getNetworkType from './getNetworkType';
// import  getSystemInfo from './getSystemInfo';

// 根据字节流下载文件
/**
 * @param {Blob} data 流数据
 * @param {String} type 下载的文件类型
 * @param {String} fileName 下载的文件名
 */
export function downloadByFlow(data,type,fileName) {
    let fileTypeMime ='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    switch (type) { // 获取后缀对应的 mimeType
      case 'png': fileTypeMime = 'image/png'; break;
      case 'doc': fileTypeMime = 'application/msword'; break;
      case 'docx': fileTypeMime = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; break;
      case 'jpg': case 'jpeg': fileTypeMime = 'image/jpeg'; break;
      case 'gif': fileTypeMime = 'image/gif'; break;
      case 'svg': fileTypeMime = 'image/svg+xml'; break;
      case 'tif': case 'tiff': fileTypeMime = 'image/tiff'; break;
      case 'txt': fileTypeMime = 'text/plain'; break;
      case 'ppt': fileTypeMime = 'application/vnd.ms-powerpoint'; break;
      case 'pptx': fileTypeMime = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; break;
      case 'xls': fileTypeMime = 'application/vnd.ms-excel'; break;
      case 'xlsx': fileTypeMime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; break;
      case 'zip': fileTypeMime = 'application/zip'; break;
      case '7z': fileTypeMime = 'application/x-7z-compressed'; break;
    }
    let blob = window.URL.createObjectURL(new Blob([data], {
      'type': fileTypeMime
    }))
    let link = document.createElement('a')
    link.style.display = 'none'
    link.href = blob
    link.setAttribute('download', fileName.indexOf('.')?fileName:`${fileName}.${type}`)
    document.body.appendChild(link)
    link.click()
    document.body.removeChild(link) //下载完成移除元素
    window.URL.revokeObjectURL(blob) //释放掉 blob 对象
  }

// export default {
//     getBrowser,
//     getNetworkType,
//     getSystemInfo
// }