MrShi
2024-02-05 5019ed6016b47221321bf395cd102dc4b51b4724
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))
    }