mirror of
https://github.com/Tencent/tdesign-vue-next-starter.git
synced 2024-12-23 12:48:28 +08:00
chore: 添加类型指定并删除冗余代码
This commit is contained in:
parent
b95de96257
commit
5edf21b1ed
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user