mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-26 22:31:21 +00:00
feat: 重构前端项目结构并优化代码
refactor: 迁移前端资源文件至web目录 feat: 新增多种图标资源 style: 统一代码风格和格式化配置 docs: 更新README和文档说明 chore: 更新依赖和配置文件 fix: 修复部分类型定义和枚举 perf: 优化路由和组件加载逻辑
This commit is contained in:
@@ -0,0 +1,160 @@
|
||||
import request from '@/utils/http';
|
||||
|
||||
const API_PATH = '/example/demo';
|
||||
|
||||
const DemoAPI = {
|
||||
/**
|
||||
* 查询演示列表
|
||||
* @param query 查询参数
|
||||
*/
|
||||
getDemoList(query: DemoPageQuery) {
|
||||
return request<PageResult<DemoTable[]>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: 'get',
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 查询演示详情
|
||||
* @param query 演示ID
|
||||
*/
|
||||
getDemoDetail(query: number) {
|
||||
return request<ApiResponse<DemoTable>>({
|
||||
url: `${API_PATH}/detail/${query}`,
|
||||
method: 'get',
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 创建演示
|
||||
* @param body 演示信息
|
||||
*/
|
||||
createDemo(body: DemoForm) {
|
||||
return request({
|
||||
url: `${API_PATH}/create`,
|
||||
method: 'post',
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新演示
|
||||
* @param id 演示ID
|
||||
* @param body 演示信息
|
||||
*/
|
||||
updateDemo(id: number, body: DemoForm) {
|
||||
return request({
|
||||
url: `${API_PATH}/update/${id}`,
|
||||
method: 'put',
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除演示
|
||||
* @param body 演示ID数组
|
||||
*/
|
||||
deleteDemo(body: number[]) {
|
||||
return request({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: 'delete',
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 批量操作演示
|
||||
* @param body 批量操作参数
|
||||
*/
|
||||
batchDemo(body: BatchType) {
|
||||
return request({
|
||||
url: `${API_PATH}/available/setting`,
|
||||
method: 'patch',
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 导出演示
|
||||
* @param body 导出参数
|
||||
*/
|
||||
exportDemo(body: DemoPageQuery) {
|
||||
return request<ApiResponse<Blob>>({
|
||||
url: `${API_PATH}/export`,
|
||||
method: 'post',
|
||||
data: body,
|
||||
responseType: 'blob',
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 下载演示模板
|
||||
*/
|
||||
downloadTemplateDemo() {
|
||||
return request({
|
||||
url: `${API_PATH}/download/template`,
|
||||
method: 'post',
|
||||
responseType: 'blob',
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 导入演示
|
||||
* @param body 导入参数
|
||||
*/
|
||||
importDemo(body: FormData) {
|
||||
return request({
|
||||
url: `${API_PATH}/import`,
|
||||
method: 'post',
|
||||
data: body,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default DemoAPI;
|
||||
|
||||
export interface DemoPageQuery extends PageQuery {
|
||||
name?: string;
|
||||
status?: string;
|
||||
created_time?: string[];
|
||||
updated_time?: string[];
|
||||
created_id?: number;
|
||||
updated_id?: number;
|
||||
}
|
||||
|
||||
export interface DemoTable extends BaseType {
|
||||
name?: string;
|
||||
status?: string;
|
||||
description?: string;
|
||||
created_by?: CommonType;
|
||||
updated_by?: CommonType;
|
||||
deleted_by?: CommonType;
|
||||
a?: number;
|
||||
b?: number;
|
||||
c?: number;
|
||||
d?: boolean;
|
||||
e?: string;
|
||||
f?: string;
|
||||
g?: string;
|
||||
h?: string;
|
||||
i?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface DemoForm extends BaseFormType {
|
||||
name?: string;
|
||||
status?: string;
|
||||
description?: string;
|
||||
a?: number;
|
||||
b?: number;
|
||||
c?: number;
|
||||
d?: boolean;
|
||||
e?: string;
|
||||
f?: Date | string;
|
||||
g?: Date | string;
|
||||
h?: string;
|
||||
i?: Record<string, any>;
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
import request from '@/utils/http';
|
||||
|
||||
const API_PATH = '/example/demo01';
|
||||
|
||||
const Demo01API = {
|
||||
/**
|
||||
* 查询演示列表
|
||||
* @param query 查询参数
|
||||
*/
|
||||
getDemo01List(query: Demo01PageQuery) {
|
||||
return request<PageResult<Demo01Table[]>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: 'get',
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 查询演示详情
|
||||
* @param id 演示ID
|
||||
*/
|
||||
getDemo01Detail(id: number) {
|
||||
return request<ApiResponse<Demo01Table>>({
|
||||
url: `${API_PATH}/detail/${id}`,
|
||||
method: 'get',
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 创建演示
|
||||
* @param body 演示信息
|
||||
*/
|
||||
createDemo01(body: Demo01Form) {
|
||||
return request({
|
||||
url: `${API_PATH}/create`,
|
||||
method: 'post',
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新演示
|
||||
* @param id 演示ID
|
||||
* @param body 演示信息
|
||||
*/
|
||||
updateDemo01(id: number, body: Demo01Form) {
|
||||
return request({
|
||||
url: `${API_PATH}/update/${id}`,
|
||||
method: 'put',
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除演示
|
||||
* @param body 演示ID列表
|
||||
*/
|
||||
deleteDemo01(body: number[]) {
|
||||
return request({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: 'delete',
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 批量设置演示状态
|
||||
* @param body 批量设置参数
|
||||
*/
|
||||
batchDemo01(body: BatchType) {
|
||||
return request({
|
||||
url: `${API_PATH}/available/setting`,
|
||||
method: 'patch',
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 导出演示
|
||||
* @param body 漼示参数
|
||||
*/
|
||||
exportDemo01(body: Demo01PageQuery) {
|
||||
return request<ApiResponse<Blob>>({
|
||||
url: `${API_PATH}/export`,
|
||||
method: 'post',
|
||||
data: body,
|
||||
responseType: 'blob',
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 下载演示模板
|
||||
*/
|
||||
downloadDemo01Template() {
|
||||
return request({
|
||||
url: `${API_PATH}/download/template`,
|
||||
method: 'post',
|
||||
responseType: 'blob',
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 导入演示
|
||||
* @param body 演示数据
|
||||
*/
|
||||
importDemo01(body: FormData) {
|
||||
return request({
|
||||
url: `${API_PATH}/import`,
|
||||
method: 'post',
|
||||
data: body,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default Demo01API;
|
||||
|
||||
export interface Demo01PageQuery extends PageQuery {
|
||||
/** 与后端 Demo01QueryParam 一致 */
|
||||
name?: string;
|
||||
description?: string;
|
||||
/** 是否启用:0 启用 / 1 禁用(字符串) */
|
||||
status?: string;
|
||||
created_time?: string[];
|
||||
updated_time?: string[];
|
||||
created_id?: number;
|
||||
updated_id?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 与后端 Demo01OutSchema 一致:
|
||||
* Demo01CreateSchema(name,status,description) + BaseSchema + UserBySchema
|
||||
*/
|
||||
export interface Demo01Table extends BaseType {
|
||||
name?: string;
|
||||
status?: string;
|
||||
description?: string;
|
||||
created_id?: number;
|
||||
updated_id?: number;
|
||||
created_by?: CommonType;
|
||||
updated_by?: CommonType;
|
||||
deleted_by?: CommonType;
|
||||
}
|
||||
|
||||
/** 与后端 Demo01CreateSchema / Demo01UpdateSchema 一致(不含 id,更新走 URL) */
|
||||
export interface Demo01Form extends BaseFormType {
|
||||
name?: string;
|
||||
status?: string;
|
||||
description?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user