update 优化 代码生成 增加多前端模板选择

This commit is contained in:
疯狂的狮子Li 2026-06-03 16:15:05 +08:00
parent 74bfd8848d
commit 5b7df709f1
3 changed files with 28 additions and 1 deletions

View File

@ -55,6 +55,7 @@ export interface DbTableVO extends Omit<TableVO, 'tableId'> {
uniqueFields?: string[];
enableSort?: boolean;
sortField?: string;
frontendType?: string;
treeRootValue?: string;
treeAncestorsField?: string;
treeOrderField?: string;
@ -79,6 +80,7 @@ export interface TableVO extends BaseEntity {
tableComment?: string;
className?: string;
tplCategory?: string;
frontendType?: string;
packageName?: string;
moduleName?: string;
businessName?: string;

View File

@ -1,5 +1,6 @@
import type { FormInstance } from 'antd';
import { Col, Form, Input, Row, Select, Switch, TreeSelect } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
import { Col, Form, Input, Radio, Row, Select, Switch, Tooltip, TreeSelect } from 'antd';
import { useMemo } from 'react';
import type { MenuVO } from '@/api/system/menu/types';
import type { DbColumnVO, DbTableVO } from '@/api/tool/gen/types';
@ -28,6 +29,10 @@ export default function GenInfoForm({ form, columns, menuOptions }: GenInfoFormP
label: `${column.columnName}${column.columnComment || ''}`,
value: column.columnName
}));
const frontendTypeOptions = [
{ label: 'Vue', value: 'vue' },
{ label: 'React', value: 'react' }
];
return (
<>
@ -42,6 +47,25 @@ export default function GenInfoForm({ form, columns, menuOptions }: GenInfoFormP
/>
</Form.Item>
</Col>
<Col xs={24} md={12}>
<Form.Item
name="frontendType"
label={
<span>
{' '}
<Tooltip title="对应后端 resources/vm 下的模板目录,例如 vue、react">
<QuestionCircleOutlined />
</Tooltip>
</span>
}
rules={[
{ required: true, message: '请选择前端模板' },
{ pattern: /^[A-Za-z0-9_-]+$/, message: '仅支持字母、数字、下划线和中划线' }
]}
>
<Radio.Group options={frontendTypeOptions} />
</Form.Item>
</Col>
<Col xs={24} md={12}>
<Form.Item name="packageName" label="生成包路径" rules={[{ required: true, message: '请输入生成包路径' }]}>
<Input />

View File

@ -30,6 +30,7 @@ function withDefaults(info: DbTableVO): DbTableVO {
uniqueFields: normalizeStringArray(info.uniqueFields),
enableSort: info.enableSort ?? false,
sortField: info.sortField ?? '',
frontendType: info.frontendType || 'react',
treeRootValue: info.treeRootValue ?? '0',
treeAncestorsField: info.treeAncestorsField ?? '',
treeOrderField: info.treeOrderField ?? ''