This commit is contained in:
dengqichen 2024-12-27 12:56:44 +08:00
parent e4816ed308
commit 5e80f9de10

View File

@ -5,6 +5,8 @@ import type {DeploymentConfig, DeployConfigTemplate, CreateDeploymentConfigReque
import {createDeploymentConfig, updateDeploymentConfig, getDeployConfigTemplates} from '../service'; import {createDeploymentConfig, updateDeploymentConfig, getDeployConfigTemplates} from '../service';
import {getApplicationList} from '../../../Application/List/service'; import {getApplicationList} from '../../../Application/List/service';
import type {Application} from '../../../Application/List/types'; import type {Application} from '../../../Application/List/types';
import {BetaSchemaForm} from '@ant-design/pro-form';
import {convertJsonSchemaToColumns} from '@/utils/jsonSchemaUtils';
import {Editor} from '@/components/Editor'; import {Editor} from '@/components/Editor';
import type {JsonNode} from '@/types/common'; import type {JsonNode} from '@/types/common';
import './styles.less'; import './styles.less';
@ -66,7 +68,7 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
} }
}, [open, fetchApplications, fetchTemplates]); }, [open, fetchApplications, fetchTemplates]);
// 始化表单数据 // <EFBFBD><EFBFBD><EFBFBD>始化表单数据
useEffect(() => { useEffect(() => {
if (!open) return; if (!open) return;
@ -117,7 +119,7 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
// 获取对应的模板 // 获取对应的模板
const template = templates.find(t => t.languageType === selectedApp.language); const template = templates.find(t => t.languageType === selectedApp.language);
if (!template) { if (!template) {
throw new Error('未找到匹配<EFBFBD><EFBFBD><EFBFBD>配置模板'); throw new Error('未找到匹配配置模板');
} }
// 构建提交数据 // 构建提交数据
@ -224,9 +226,11 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
{/* 动态构建配置 */} {/* 动态构建配置 */}
{selectedTemplate?.buildVariablesSchema?.properties && ( {selectedTemplate?.buildVariablesSchema?.properties && (
Object.entries(selectedTemplate.buildVariablesSchema.properties).map(([key, property]) => { <>
if (property.editorConfig) { {/* 富文本编辑器字段 */}
return ( {Object.entries(selectedTemplate.buildVariablesSchema.properties)
.filter(([_, property]) => property.editorConfig)
.map(([key, property]) => (
<Form.Item <Form.Item
key={key} key={key}
label={ label={
@ -268,10 +272,10 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
renderWhitespace: 'boundary', renderWhitespace: 'boundary',
}} }}
loading={ loading={
<div style={{ <div style={{
padding: '8px', padding: '8px',
display: 'flex', display: 'flex',
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
height: '300px', height: '300px',
background: '#1e1e1e', background: '#1e1e1e',
@ -282,24 +286,28 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
} }
/> />
</Form.Item> </Form.Item>
); ))
} }
return ( {/* 普通字段 */}
<Form.Item {Object.entries(selectedTemplate.buildVariablesSchema.properties)
key={key} .filter(([_, property]) => !property.editorConfig)
label={property.title || key} .map(([key, property]) => (
required={selectedTemplate.buildVariablesSchema.required?.includes(key)} <Form.Item
tooltip={property.description} key={key}
> label={property.title || key}
<Input required={selectedTemplate.buildVariablesSchema.required?.includes(key)}
value={buildVariables[key] || property.default || ''} tooltip={property.description}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleInputChange(key, e.target.value)} >
placeholder={`请输入${property.title || key}`} <Input
/> value={buildVariables[key] || property.default || ''}
</Form.Item> onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleInputChange(key, e.target.value)}
); placeholder={`请输入${property.title || key}`}
}) />
</Form.Item>
))
}
</>
)} )}
{/* 状态和排序 */} {/* 状态和排序 */}
@ -325,7 +333,7 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
styles={{ styles={{
body: { padding: 0 }, body: { padding: 0 },
mask: { backgroundColor: 'rgba(0, 0, 0, 0.65)' }, mask: { backgroundColor: 'rgba(0, 0, 0, 0.65)' },
content: { content: {
position: 'fixed', position: 'fixed',
top: 0, top: 0,
left: 0, left: 0,