jiangping
2024-01-26 a76c5c86ac9af71da45bf78c825a2c7aa843b4c8
platform/src/plugins/download.js
@@ -2,11 +2,12 @@
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))
    }