保存进度!

This commit is contained in:
Kane Wang 2023-06-12 18:29:24 +08:00
parent 24266203ca
commit 0e1338e54b
2 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,64 @@
/*
* @Author: Kane
* @Date: 2023-06-12 14:48:55
* @LastEditors: Kane
* @FilePath: /task_schedule/src/utils/api/loginRequest.ts
* @Description:
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
*/
import axios, { type AxiosInstance } from "axios";
const loginInstance: AxiosInstance = axios.create(
{
baseURL: "",
timeout: 10000,
}
);
// 拦截器
// 登录用的请求不需要加上token。
loginInstance.interceptors.request.use(
/**
*
* token
* @param config axios传递的配置对象
* @returns axios的配置对象
*/
( config ) =>
{
return config;
},
/**
*
* @param reason axios
* @returns Promise对象
*/
async ( reason ) =>
{
return await Promise.reject( reason );
});
// 响应拦截器
loginInstance.interceptors.response.use(
/**
*
* @param response axios传递的响应结果
* @returns
*/
( response ) =>
{
return response;
},
/**
* 2xx时被调用
* @param error axios传递的错误内容
* @returns
*/
async ( error ) =>
{
return await Promise.reject( error );
});
export { loginInstance as instance };

View File

@ -19,8 +19,15 @@ const service: AxiosInstance = axios.create(
// 请求拦截
service.interceptors.request.use(
/**
* token
* @param config ,token
* @returns
*/
( config ) =>
{
config.headers.token = "123";
return config;
},
async ( error ) =>