feat: 请求错误拦截提示

This commit is contained in:
baiqi 2023-07-17 16:47:57 +08:00 committed by jianxing
parent c979e9ee7f
commit 905a7b640b
2 changed files with 11 additions and 11 deletions

View File

@ -17,35 +17,35 @@ export default function checkStatus(status: number, msg: string, errorMessageMod
break; break;
} }
case 403: case 403:
errMessage = t('api.errMsg403'); errMessage = msg || t('api.errMsg403');
break; break;
// 404请求不存在 // 404请求不存在
case 404: case 404:
errMessage = t('api.errMsg404'); errMessage = msg || t('api.errMsg404');
break; break;
case 405: case 405:
errMessage = t('api.errMsg405'); errMessage = msg || t('api.errMsg405');
break; break;
case 408: case 408:
errMessage = t('api.errMsg408'); errMessage = msg || t('api.errMsg408');
break; break;
case 500: case 500:
errMessage = t('api.errMsg500'); errMessage = msg || t('api.errMsg500');
break; break;
case 501: case 501:
errMessage = t('api.errMsg501'); errMessage = msg || t('api.errMsg501');
break; break;
case 502: case 502:
errMessage = t('api.errMsg502'); errMessage = msg || t('api.errMsg502');
break; break;
case 503: case 503:
errMessage = t('api.errMsg503'); errMessage = msg || t('api.errMsg503');
break; break;
case 504: case 504:
errMessage = t('api.errMsg504'); errMessage = msg || t('api.errMsg504');
break; break;
case 505: case 505:
errMessage = t('api.errMsg505'); errMessage = msg || t('api.errMsg505');
break; break;
default: default:
} }

View File

@ -132,7 +132,7 @@ const transform: AxiosTransform = {
const { t } = useI18n(); const { t } = useI18n();
const { response, code, message, config } = error || {}; const { response, code, message, config } = error || {};
const errorMessageMode = config?.requestOptions?.errorMessageMode || 'none'; const errorMessageMode = config?.requestOptions?.errorMessageMode || 'none';
const msg: string = response?.data?.error?.message ?? ''; const msg: string = response?.data?.message ?? '';
const err: string = error?.toString?.() ?? ''; const err: string = error?.toString?.() ?? '';
let errMessage = ''; let errMessage = '';