chore: 添加类型指定并删除冗余代码

This commit is contained in:
悠静萝莉 2022-06-22 20:18:07 +08:00
parent b95de96257
commit 5edf21b1ed
No known key found for this signature in database
GPG Key ID: 4EDF1CA1CEA8EBCC

View File

@ -1,4 +1,4 @@
import axios from 'axios'; import axios, { AxiosInstance } from 'axios';
import proxy from '../config/proxy'; import proxy from '../config/proxy';
const env = import.meta.env.MODE || 'development'; const env = import.meta.env.MODE || 'development';
@ -8,19 +8,15 @@ const host = env === 'mock' ? '/' : proxy[env].host; // 如果是mock模式 就
const CODE = { const CODE = {
LOGIN_TIMEOUT: 1000, LOGIN_TIMEOUT: 1000,
REQUEST_SUCCESS: 0, REQUEST_SUCCESS: 0,
REQUEST_FOBID: 1001, REQUEST_FAILED: 1001,
}; };
const instance = axios.create({ const instance: AxiosInstance = axios.create({
baseURL: host, baseURL: host,
timeout: 1000, timeout: 5000,
withCredentials: true, withCredentials: true,
}); });
instance.interceptors.request.use((config) => config);
instance.defaults.timeout = 5000;
instance.interceptors.response.use( instance.interceptors.response.use(
(response) => { (response) => {
if (response.status === 200) { if (response.status === 200) {