项目首次提交

This commit is contained in:
2026-03-11 10:53:53 +08:00
commit ad2c4fa47a
139 changed files with 29061 additions and 0 deletions
+77
View File
@@ -0,0 +1,77 @@
import { IHttpResponse, IObject } from "@/types/interface";
import http from "../utils/http";
/**
* 常用CRUD
*/
export default {
/**
* 删除
* @param path
* @param params
* @returns
*/
delete(path: string, params: IObject): Promise<IHttpResponse> {
return http({
url: path,
data: params,
method: "DELETE"
});
},
get(path: string, params?: IObject, headers?: IObject): Promise<IHttpResponse> {
return new Promise((resolve, reject) => {
http({
url: path,
params,
headers,
method: "GET"
})
.then(resolve)
.catch((error) => {
if (error !== "-999") {
reject(error);
}
});
});
},
put(path: string, params?: IObject, headers?: IObject): Promise<IHttpResponse> {
return http({
url: path,
data: params,
headers: {
"Content-Type": "application/json;charset=UTF-8",
...headers
},
method: "PUT"
});
},
/**
* 通用post方法
* @param path
* @param body
* @returns
*/
post(path: string, body?: IObject, headers?: IObject): Promise<IHttpResponse> {
return http({
url: path,
method: "post",
headers: {
"Content-Type": "application/json;charset=UTF-8",
...headers
},
data: body
});
},
// 在 baseService.ts 中添加
upload(path: string, formData: FormData, headers?: IObject): Promise<IHttpResponse> {
return http({
url: path,
method: "post",
// 关键:不要在这里设置 Content-Type,让浏览器/Axios 自动处理
headers: {
...headers
},
data: formData
});
}
};