File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -282,6 +282,17 @@ export const exportFile: (
282282 transformResponse : [
283283 function ( data , headers ) {
284284 // 在这里可以访问 headers
285+ if ( data . type === 'application/json' ) {
286+ data . text ( ) . then ( ( text : string ) => {
287+ try {
288+ const json = JSON . parse ( text )
289+ MsgError ( json . message || text )
290+ } catch {
291+ MsgError ( text )
292+ }
293+ } )
294+ throw new Error ( 'Response is not a valid file' )
295+ }
285296 // const contentType = headers['content-type'];
286297 const contentDisposition = headers [ 'content-disposition' ]
287298 // console.log('Content-Type:', contentType);
@@ -306,7 +317,7 @@ export const exportFile: (
306317 window . URL . revokeObjectURL ( link . href )
307318 }
308319 return true
309- } )
320+ } ) . catch ( ( ) => { } )
310321}
311322
312323export const exportExcelPost : (
You can’t perform that action at this time.
0 commit comments