jiangping
2024-02-18 05cf6324ea8322164d99a3d3d4161fe374534b3b
platform/src/plugins/download.js
@@ -2,12 +2,11 @@
import message from './message'
export default function (response, decode = true, mime = 'application/octet-stream') {
  debugger
  // 当下载接口没有成功返回流并且接口返回的是JSON时需要对响应流进行解析并提示错误。(处理下载接口出现未知异常的情况)
  if (response.headers['content-type'] === 'application/json') {
    const blob = new Blob([response.data])
    const fileReader = new FileReader()
    fileReader.readAsText(blob, 'UTF-8')
    fileReader.readAsText(blob, 'utf-8')
    fileReader.onload = function () {
      message.apiFailed(JSON.parse(fileReader.result))
    }