فهرست منبع

Merge branch 'master' of http://192.168.1.41:3000/lanjianrong/cldV2_console

outaozhen 2 سال پیش
والد
کامیت
aab3ab330b
1فایلهای تغییر یافته به همراه9 افزوده شده و 9 حذف شده
  1. 9 9
      src/app.tsx

+ 9 - 9
src/app.tsx

@@ -1,11 +1,12 @@
 import type { Settings as LayoutSettings } from '@ant-design/pro-layout'
 import { notification } from 'antd'
 import type { RequestConfig, RunTimeLayoutConfig } from '@umijs/max'
-import { getIntl, getLocale, history } from '@umijs/max'
+import { history } from '@umijs/max'
 import RightContent from '@/components/RightContent'
 import { currentUser as queryCurrentUser } from './services/user/api'
 import consts from './utils/consts'
 import defaultSettings from '../config/defaultSettings'
+import { isNullOrUnDef, isObject } from './utils/is'
 const loginPath = '/user/login'
 
 /**
@@ -109,14 +110,13 @@ export const request: RequestConfig = {
   },
   responseInterceptors: [
     async response => {
-      const { data, code: errorCode, msg: errorMessage } = response.data
-      if (!errorCode || errorCode !== consts.RET_CODE.SUCCESS) {
-        if (errorCode !== consts.RET_CODE.SUCCESS) {
-          const error: any = new Error(errorMessage)
-          error.name = 'BizError'
-          error.info = { errorCode, errorMessage, data }
-          throw error
-        }
+      const { data, code: errorCode, msg } = response.data
+      if (isNullOrUnDef(errorCode) || errorCode !== consts.RET_CODE.SUCCESS) {
+        const errorMessage = isObject(msg) ? JSON.stringify(msg) : msg
+        const error: any = new Error(errorMessage)
+        error.name = 'BizError'
+        error.info = { errorCode, errorMessage, data }
+        throw error
       }
       return Promise.resolve(response)
     }