|
@@ -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)
|
|
|
}
|