| | |
| | | data: typeof config.data === 'object' ? JSON.stringify(config.data) : config.data, |
| | | time: new Date().getTime() |
| | | } |
| | | const requestSize = Object.keys(JSON.stringify(requestObj)).length; // 请求数据大小 |
| | | const limitSize = 5 * 1024 * 1024; // 限制存放数据5M |
| | | if (requestSize >= limitSize) { |
| | | console.warn(`[${config.url}]: ` + '请求数据大小超出允许的5M限制,无法进行防重复提交验证。') |
| | | return config; |
| | | } |
| | | const sessionObj = cache.session.getJSON('sessionObj') |
| | | if (sessionObj === undefined || sessionObj === null || sessionObj === '') { |
| | | cache.session.setJSON('sessionObj', requestObj) |
| | |
| | | // 获取错误信息 |
| | | const msg = errorCode[code] || res.data.msg || errorCode['default'] |
| | | // 二进制数据则直接返回 |
| | | if(res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer'){ |
| | | if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') { |
| | | return res.data |
| | | } |
| | | if (code === 401) { |
| | |
| | | responseType: 'blob', |
| | | ...config |
| | | }).then(async (data) => { |
| | | const isLogin = await blobValidate(data); |
| | | if (isLogin) { |
| | | const isBlob = blobValidate(data); |
| | | if (isBlob) { |
| | | const blob = new Blob([data]) |
| | | saveAs(blob, filename) |
| | | } else { |