mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 04:46:26 +00:00
refactor(gencode): 优化代码生成API接口和类型定义
修复前端快速链接布局和样式问题 删除无用工作流模块文件 更新系统菜单权限配置
This commit is contained in:
@@ -5,7 +5,7 @@ const API_PATH = "/generator/gencode";
|
||||
const GencodeAPI = {
|
||||
// 查询生成表数据
|
||||
listTable(query: TablePageQuery) {
|
||||
return request<ApiResponse<PageResult<GenTableOutVO>>>({
|
||||
return request<ApiResponse<PageResult<GenTableOutVO[]>>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: 'get',
|
||||
params: query
|
||||
@@ -13,14 +13,23 @@ const GencodeAPI = {
|
||||
},
|
||||
|
||||
// 查询db数据库列表
|
||||
listDbTable(query: DBTablePageQuery) {
|
||||
return request<ApiResponse<PageResult<TablePageVO>>>({
|
||||
listDbTable(query: TablePageQuery) {
|
||||
return request<ApiResponse<PageResult<TablePageVO[]>>>({
|
||||
url: `${API_PATH}/db/list`,
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
},
|
||||
|
||||
// 导入表
|
||||
importTable(table_names: string[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/import`,
|
||||
method: 'post',
|
||||
data: { table_names }
|
||||
})
|
||||
},
|
||||
|
||||
// 查询表详细信息
|
||||
getGenTableDetail(table_id: number) {
|
||||
return request<ApiResponse<GenTableDetailResult>>({
|
||||
@@ -39,29 +48,11 @@ const GencodeAPI = {
|
||||
},
|
||||
|
||||
// 修改代码生成信息
|
||||
updateGenTable(data: GenTableUpdateSchema) {
|
||||
updateGenTable(table_id: number, data: GenTableUpdateSchema) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/update`,
|
||||
url: `${API_PATH}/update/${table_id}`,
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
},
|
||||
|
||||
// 导入表
|
||||
importTable(tables: string[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/import`,
|
||||
method: 'post',
|
||||
data: { tables }
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
// 预览生成代码
|
||||
previewTable(tableId: number) {
|
||||
return request<ApiResponse<GeneratorPreviewVO[]>>({
|
||||
url: `${API_PATH}/preview/${tableId}`,
|
||||
method: 'get'
|
||||
data: data
|
||||
})
|
||||
},
|
||||
|
||||
@@ -75,27 +66,35 @@ const GencodeAPI = {
|
||||
},
|
||||
|
||||
// 批量生成代码
|
||||
batchGenCode(tables: string) {
|
||||
batchGenCode(table_names: string[]) {
|
||||
return request<Blob>({
|
||||
url: `${API_PATH}/batch/out`,
|
||||
url: `${API_PATH}/batch/output`,
|
||||
method: 'patch',
|
||||
params: { tables },
|
||||
params: { table_names },
|
||||
responseType: 'blob'
|
||||
})
|
||||
},
|
||||
|
||||
// 生成代码到指定路径
|
||||
genCodeToPath(tableName: string) {
|
||||
genCodeToPath(table_name: string) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/out/path/${tableName}`,
|
||||
url: `${API_PATH}/output/${table_name}`,
|
||||
method: 'post'
|
||||
})
|
||||
},
|
||||
|
||||
// 预览生成代码
|
||||
previewTable(table_id: number) {
|
||||
return request<ApiResponse<GeneratorPreviewVO[]>>({
|
||||
url: `${API_PATH}/preview/${table_id}`,
|
||||
method: 'get'
|
||||
})
|
||||
},
|
||||
|
||||
// 同步数据库
|
||||
syncDb(tableName: string) {
|
||||
syncDb(table_name: string) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/sync/db/${tableName}`,
|
||||
url: `${API_PATH}/synch_db/${table_name}`,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
@@ -125,12 +124,6 @@ export interface TablePageQuery extends PageQuery {
|
||||
end_time?: string;
|
||||
}
|
||||
|
||||
/** 数据库表分页查询参数 */
|
||||
export interface DBTablePageQuery extends PageQuery {
|
||||
/** 数据库列名称 */
|
||||
column_name?: string;
|
||||
}
|
||||
|
||||
/** 数据表分页对象 */
|
||||
export interface TablePageVO {
|
||||
/** 表名称 */
|
||||
|
||||
@@ -138,7 +138,7 @@
|
||||
<ElCol
|
||||
v-for="(item, index) in quickLinks"
|
||||
:key="index"
|
||||
:span="8"
|
||||
:span="6"
|
||||
class="group mb-4"
|
||||
>
|
||||
<ElButton
|
||||
@@ -147,16 +147,16 @@
|
||||
class="w-full relative"
|
||||
@click="handleQuickLinkClick(item)"
|
||||
>
|
||||
<el-icon v-if="item.icon && item.icon.startsWith('el-icon')">
|
||||
<el-icon v-if="item.icon && item.icon.startsWith('el-icon')" :color="getRandomColor()">
|
||||
<component :is="item.icon.replace('el-icon-', '')" />
|
||||
</el-icon>
|
||||
<div v-else-if="item.icon" :class="`i-svg:${item.icon} mr-2`" />
|
||||
<div v-else :class="`i-svg:menu mr-2`" />
|
||||
<div v-else-if="item.icon" :class="`i-svg:${item.icon} mr-2`" :style="{ color: getRandomColor() }" />
|
||||
<div v-else :class="`i-svg:menu mr-2`" :style="{ color: getRandomColor() }" />
|
||||
|
||||
<span>{{ item.title }}</span>
|
||||
<el-icon
|
||||
color="var(--el-color-danger)"
|
||||
class="absolute top-2 right-2 opacity-0 group-hover:opacity-100 "
|
||||
class="absolute top-0 right-0 opacity-0 group-hover:opacity-100 "
|
||||
@click.stop="handleDeleteLink(item)"
|
||||
>
|
||||
<CircleClose />
|
||||
@@ -277,6 +277,17 @@ const handleQuickLinkClick = (item: QuickLink) => {
|
||||
}
|
||||
};
|
||||
|
||||
const getRandomColor = () => {
|
||||
// 预定义几个亮且鲜艳的颜色
|
||||
const colors = [
|
||||
'#FF5733', '#33FF57', '#3357FF', '#FF33E6',
|
||||
'#FFFF33', '#33FFFF', '#FF3333', '#5733FF',
|
||||
'#33FFE6', '#E633FF'
|
||||
];
|
||||
// 随机选择一个颜色返回
|
||||
const randomIndex = Math.floor(Math.random() * colors.length);
|
||||
return colors[randomIndex];
|
||||
}
|
||||
// 处理删除链接
|
||||
const handleDeleteLink = (item: QuickLink) => {
|
||||
ElMessageBox.confirm(
|
||||
|
||||
Reference in New Issue
Block a user