Merge remote-tracking branch 'origin/master'
						commit
						fb33d662f6
					
				| 
						 | 
				
			
			@ -126,14 +126,13 @@ export class VAxios {
 | 
			
		|||
      const config = res.config
 | 
			
		||||
      // 二进制数据则直接返回,例如说 Excel 导出
 | 
			
		||||
      if (
 | 
			
		||||
        res.request.responseType === 'blob' ||
 | 
			
		||||
        res.request.responseType === 'arraybuffer'
 | 
			
		||||
        res.request.responseType === 'blob'
 | 
			
		||||
        || res.request.responseType === 'arraybuffer'
 | 
			
		||||
      ) {
 | 
			
		||||
        // 注意:如果导出的响应为 json,说明可能失败了,不直接返回进行下载
 | 
			
		||||
        if (res.data.type === 'application/json') {
 | 
			
		||||
        if (res.data.type === 'application/json')
 | 
			
		||||
          res.data = await new Response(res.data).json()
 | 
			
		||||
      }
 | 
			
		||||
      }
 | 
			
		||||
      // 处理 accessToken 过期的情况
 | 
			
		||||
      if (res.data.code === 401) {
 | 
			
		||||
        // 如果未认证,并且未进行刷新令牌,说明可能是访问令牌过期了
 | 
			
		||||
| 
						 | 
				
			
			@ -298,12 +297,18 @@ export class VAxios {
 | 
			
		|||
              reject(err || new Error('request error!'))
 | 
			
		||||
            }
 | 
			
		||||
            // 注释 return,解决无法导出的问题。参见 https://t.zsxq.com/79cmo 说明。
 | 
			
		||||
            // return
 | 
			
		||||
          }
 | 
			
		||||
          else {
 | 
			
		||||
            resolve(res as unknown as Promise<T>)
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          // download file
 | 
			
		||||
          if (typeof res != 'undefined')
 | 
			
		||||
          if (res && typeof res !== 'undefined' && res.headers) {
 | 
			
		||||
            const contentType = res.headers['content-type']
 | 
			
		||||
            // ExcelUtils.java的write函数setContentType顺序问题,导致没有contentType
 | 
			
		||||
            if (!contentType || !contentType.startsWith('application/json'))
 | 
			
		||||
              downloadByData(res?.data as unknown as BlobPart, title || 'export')
 | 
			
		||||
          }
 | 
			
		||||
        })
 | 
			
		||||
        .catch((e: Error | AxiosError) => {
 | 
			
		||||
          if (requestCatchHook && isFunction(requestCatchHook)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -344,7 +349,6 @@ export class VAxios {
 | 
			
		|||
      this.axiosInstance
 | 
			
		||||
        .request<any, AxiosResponse<Result>>(conf)
 | 
			
		||||
        .then((res: AxiosResponse<Result>) => {
 | 
			
		||||
          debugger
 | 
			
		||||
          if (transformResponseHook && isFunction(transformResponseHook)) {
 | 
			
		||||
            try {
 | 
			
		||||
              const ret = transformResponseHook(res, opt)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue