|
@ -12,7 +12,7 @@ interface Result { |
|
|
interface ResultData<T = any> extends Result { |
|
|
interface ResultData<T = any> extends Result { |
|
|
data?: T |
|
|
data?: T |
|
|
} |
|
|
} |
|
|
const URL: string = serviceUrls.yiyanService |
|
|
const URL: string = serviceUrls.baseService |
|
|
enum RequestEnums { |
|
|
enum RequestEnums { |
|
|
TIMEOUT = 20000, |
|
|
TIMEOUT = 20000, |
|
|
OVERDUE = 600, // 登录失效
|
|
|
OVERDUE = 600, // 登录失效
|
|
@ -40,16 +40,16 @@ class RequestHttp { |
|
|
* 客户端发送请求 -> [请求拦截器] -> 服务器 |
|
|
* 客户端发送请求 -> [请求拦截器] -> 服务器 |
|
|
* token校验(JWT) : 接受服务器返回的token,存储到vuex/pinia/本地储存当中 |
|
|
* token校验(JWT) : 接受服务器返回的token,存储到vuex/pinia/本地储存当中 |
|
|
*/ |
|
|
*/ |
|
|
this.service.interceptors.request.use( |
|
|
// this.service.interceptors.request.use(
|
|
|
(config: InternalAxiosRequestConfig) => { |
|
|
// (config: InternalAxiosRequestConfig) => {
|
|
|
config.headers['Authorization'] = localStorage.getItem('token') || '' |
|
|
// config.headers['Authorization'] = localStorage.getItem('token') || ''
|
|
|
return config |
|
|
// return config
|
|
|
}, |
|
|
// },
|
|
|
(error: AxiosError) => { |
|
|
// (error: AxiosError) => {
|
|
|
// 请求报错
|
|
|
// // 请求报错
|
|
|
Promise.reject(error) |
|
|
// Promise.reject(error)
|
|
|
} |
|
|
// }
|
|
|
) |
|
|
// )
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 响应拦截器 |
|
|
* 响应拦截器 |
|
|