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