保存进度!

This commit is contained in:
2025-12-25 23:37:43 +08:00
parent 534d7c4d01
commit 5c410e3837

View File

@@ -0,0 +1,59 @@
/**
* @Author: Kane Wang <wangkane@qq.com>
* @Date: 2025-12-18 10:02:42
* @LastEditors: Kane Wang
* @LastModified: 2025-12-25 18:01:56
* @FilePath: src/utils/api/request.ts
* @Description:
*
* Copyright (c) 2025 by Kane All rights reserved
*/
import axios, {type AxiosInstance } from "axios";
const service: AxiosInstance = axios.create(
{
baseURL: "",
timeout: 30000,
}
);
// #region 1111
// #endregion
// 请求拦截
service.interceptors.request.use(
/**
* 请求拦截器config对象用于给开发人员配置请求
* @param config 配置对象在配置中加入需要的token
* @returns 返回配置好的config
*/
( config ) =>
{
config.headers.token = "123";
return config;
},
async ( error: any ) =>
{
console.log( `配置请求拦截器错误:${error}` );
return await Promise.reject( error );
}
);
/**
* 响应拦截器
*/
service.interceptors.response.use(
( response ) =>
{
return response;
},
async ( error ) =>
{
console.log( `配置响应拦截器失败:${error}` );
return await Promise.reject( error );
}
);
export { service };