diff --git a/src/utils/service.ts b/src/utils/service.ts index 1fec642..930a593 100644 --- a/src/utils/service.ts +++ b/src/utils/service.ts @@ -20,9 +20,8 @@ function createService() { // apiData 是 api 返回的数据 const apiData = response.data // 二进制数据则直接返回 - if (response.request.responseType === "blob" || response.request.responseType === "arraybuffer") { - return apiData - } + const responseType = response.request?.responseType + if (responseType === "blob" || responseType === "arraybuffer") return apiData // 这个 code 是和后端约定的业务 code const code = apiData.code // 如果没有 code, 代表这不是项目后端开发的 api diff --git a/src/utils/validate.ts b/src/utils/validate.ts index 7ebf161..2092594 100644 --- a/src/utils/validate.ts +++ b/src/utils/validate.ts @@ -5,7 +5,7 @@ export const isArray = (arg: unknown) => { /** 判断是否为字符串 */ export const isString = (str: unknown) => { - return typeof str === "string" || str instanceof String || false + return typeof str === "string" || str instanceof String } /** 判断是否为外链 */