fix: 抽离接口异常code
This commit is contained in:
@@ -4,7 +4,7 @@ import type { Result } from './axios.d';
|
||||
import { NsMessage } from '/nerv-lib/component/message';
|
||||
import { routerConfig } from '/nerv-base/config/router.config';
|
||||
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 {
|
||||
private instance: AxiosInstance;
|
||||
@@ -75,14 +75,6 @@ export class NSAxios {
|
||||
return config;
|
||||
}, undefined);
|
||||
|
||||
const errCodeMap = new Map<number, any>([
|
||||
[13, ''],
|
||||
[1, ''],
|
||||
[11, ''],
|
||||
[3005, ''],
|
||||
[10086, () => routerConfig.logout()],
|
||||
]);
|
||||
|
||||
// type closeType = (() => void) | undefined;
|
||||
this.instance.interceptors.response.use(
|
||||
(res: AxiosResponse) => {
|
||||
@@ -90,8 +82,6 @@ export class NSAxios {
|
||||
const code = res?.data?.retcode;
|
||||
const msg = res?.data?.msg;
|
||||
if (errCodeMap.has(code)) {
|
||||
console.log(errCodeMap.get(code));
|
||||
|
||||
NsMessage.error({
|
||||
content: msg,
|
||||
key: this.errorMsgKey,
|
||||
|
Reference in New Issue
Block a user