From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/config/axios/index.ts | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/src/config/axios/index.ts b/src/config/axios/index.ts
new file mode 100644
index 0000000..36bddc2
--- /dev/null
+++ b/src/config/axios/index.ts
@@ -0,0 +1,48 @@
+import { service } from './service'
+
+import { config } from './config'
+
+const { default_headers } = config
+
+const request = (option: any) => {
+ const { headersType, headers, ...otherOption } = option
+ return service({
+ ...otherOption,
+ headers: {
+ 'Content-Type': headersType || default_headers,
+ ...headers
+ }
+ })
+}
+export default {
+ get: async <T = any>(option: any) => {
+ const res = await request({ method: 'GET', ...option })
+ return res.data as unknown as T
+ },
+ post: async <T = any>(option: any) => {
+ const res = await request({ method: 'POST', ...option })
+ return res.data as unknown as T
+ },
+ postOriginal: async (option: any) => {
+ const res = await request({ method: 'POST', ...option })
+ return res
+ },
+ delete: async <T = any>(option: any) => {
+ const res = await request({ method: 'DELETE', ...option })
+ return res.data as unknown as T
+ },
+ put: async <T = any>(option: any) => {
+ const res = await request({ method: 'PUT', ...option })
+ return res.data as unknown as T
+ },
+ download: async <T = any>(option: any) => {
+ const res = await request({ method: 'GET', responseType: 'blob', ...option })
+ return res as unknown as Promise<T>
+ },
+ upload: async <T = any>(option: any) => {
+ option.headersType = 'multipart/form-data'
+ console.log(option)
+ const res = await request({ method: 'POST', ...option })
+ return res as unknown as Promise<T>
+ }
+}
--
Gitblit v1.8.0