import { saveAs } from 'file-saver'
import axios from 'axios'
import { ElMessage } from 'element-plus'

export function downLoadFile(url: string, name: string) {
  axios.get(url).then(res => {
    console.log(url, name)
    const oReq = new XMLHttpRequest()
    oReq.open('GET', url, true)
    oReq.responseType = 'blob'
    oReq.onload = function () {
      const file = new Blob([oReq.response], {
        type: 'blob',
      })
      saveAs.saveAs(file, name)
    }
    oReq.send()
  }).catch(err => {
    ElMessage.error("视频生成异常，请联系客服处理！")
  });
}
