|
@ -4,7 +4,7 @@ import type { Result } from './axios.d'; |
|
|
import { NsMessage } from '/nerv-lib/component/message'; |
|
|
import { NsMessage } from '/nerv-lib/component/message'; |
|
|
import { routerConfig } from '/nerv-base/config/router.config'; |
|
|
import { routerConfig } from '/nerv-base/config/router.config'; |
|
|
import { Cookies } from '/nerv-lib/util/cookie'; |
|
|
import { Cookies } from '/nerv-lib/util/cookie'; |
|
|
import { RequestEnum } from '/@/enum/http-enum.ts'; |
|
|
import { RequestEnum, errCodeMap } from '/@/enum/http-enum.ts'; |
|
|
|
|
|
|
|
|
export class NSAxios { |
|
|
export class NSAxios { |
|
|
private instance: AxiosInstance; |
|
|
private instance: AxiosInstance; |
|
@ -75,14 +75,6 @@ export class NSAxios { |
|
|
return config; |
|
|
return config; |
|
|
}, undefined); |
|
|
}, undefined); |
|
|
|
|
|
|
|
|
const errCodeMap = new Map<number, any>([ |
|
|
|
|
|
[13, ''], |
|
|
|
|
|
[1, ''], |
|
|
|
|
|
[11, ''], |
|
|
|
|
|
[3005, ''], |
|
|
|
|
|
[10086, () => routerConfig.logout()], |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
// type closeType = (() => void) | undefined;
|
|
|
// type closeType = (() => void) | undefined;
|
|
|
this.instance.interceptors.response.use( |
|
|
this.instance.interceptors.response.use( |
|
|
(res: AxiosResponse) => { |
|
|
(res: AxiosResponse) => { |
|
@ -90,8 +82,6 @@ export class NSAxios { |
|
|
const code = res?.data?.retcode; |
|
|
const code = res?.data?.retcode; |
|
|
const msg = res?.data?.msg; |
|
|
const msg = res?.data?.msg; |
|
|
if (errCodeMap.has(code)) { |
|
|
if (errCodeMap.has(code)) { |
|
|
console.log(errCodeMap.get(code)); |
|
|
|
|
|
|
|
|
|
|
|
NsMessage.error({ |
|
|
NsMessage.error({ |
|
|
content: msg, |
|
|
content: msg, |
|
|
key: this.errorMsgKey, |
|
|
key: this.errorMsgKey, |
|
|