blob: 7701fc02d9033067ab927119d6f91e33425a0dbc [file] [log] [blame]
San3yuan4d0e8032025-04-04 17:21:40 +08001import axios, { AxiosRequestConfig, AxiosResponse } from 'axios'
2import instance from './axios'
3
4// 封装基础请求方法
5const request = {
6 get<T = any>(url: string, config?: AxiosRequestConfig): Promise<T> {
7 return instance.get(url, config)
8 },
9
10 post<T = any>(
11 url: string,
12 data?: any,
13 config?: AxiosRequestConfig
14 ): Promise<T> {
15 return instance.post(url, data, config)
16 },
17
18 put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T> {
19 return instance.put(url, data, config)
20 },
21
22 delete<T = any>(url: string, config?: AxiosRequestConfig): Promise<T> {
23 return instance.delete(url, config)
24 }
25}
26
27// 开发环境启用 Mock
28if (process.env.NODE_ENV === 'development') {
29 require('../mock') // 你的 Mock 配置文件
30}
31
32
33export default request