mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
build(projects): 依赖升级
This commit is contained in:
@ -1,8 +1,2 @@
|
||||
/** 请求超时时间 */
|
||||
export const REQUEST_TIMEOUT = 15 * 1000;
|
||||
|
||||
/** 请求头的content-type类型 */
|
||||
export enum ContentType {
|
||||
json = 'application/json',
|
||||
formUrlEncoded = 'application/x-www-form-urlencoded'
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
const ERROR_STATUS = {
|
||||
400: '400: 请求出现语法错误',
|
||||
401: '401: 用户未授权~',
|
||||
@ -21,20 +19,21 @@ type ErrorStatus = keyof typeof ERROR_STATUS;
|
||||
* @param error - 错误
|
||||
*/
|
||||
export function errorHandler(error: any): void {
|
||||
const { $message: Message } = window;
|
||||
if (error.response) {
|
||||
const status = error.response.status as ErrorStatus;
|
||||
ElMessage.error(ERROR_STATUS[status]);
|
||||
Message?.error(ERROR_STATUS[status]);
|
||||
return;
|
||||
}
|
||||
if (error.code === 'ECONNABORTED' && error.message.includes('timeout')) {
|
||||
ElMessage.error('网络连接超时~');
|
||||
Message?.error('网络连接超时~');
|
||||
return;
|
||||
}
|
||||
if (!window.navigator.onLine || error.message === 'Network Error') {
|
||||
ElMessage.error('网络不可用~');
|
||||
Message?.error('网络不可用~');
|
||||
return;
|
||||
}
|
||||
ElMessage.error('请求错误~');
|
||||
Message?.error('请求错误~');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,5 @@
|
||||
import axios from 'axios';
|
||||
import qs from 'qs';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import type { AxiosRequestConfig, AxiosInstance } from 'axios';
|
||||
import { ContentType } from '@/enum';
|
||||
import { getStorageToken } from '@/utils';
|
||||
@ -68,7 +67,7 @@ export default class CustomAxiosInstance {
|
||||
if (data[statusKey] === successCode) {
|
||||
return Promise.resolve(data.data);
|
||||
}
|
||||
ElMessage.error(data[msgKey]);
|
||||
window.$message?.error(data[msgKey]);
|
||||
return Promise.reject(data[msgKey]);
|
||||
}
|
||||
const error = { response };
|
||||
|
Reference in New Issue
Block a user