From e4816ed3088f7b1ce5b26423b3838f1df30cdb23 Mon Sep 17 00:00:00 2001 From: dengqichen Date: Fri, 27 Dec 2024 11:25:11 +0800 Subject: [PATCH] 1 --- .../List/components/DeploymentConfigModal.tsx | 333 +++++++++++------- 1 file changed, 196 insertions(+), 137 deletions(-) diff --git a/frontend/src/pages/Deploy/Deployment/List/components/DeploymentConfigModal.tsx b/frontend/src/pages/Deploy/Deployment/List/components/DeploymentConfigModal.tsx index d01de856..cb3365f9 100644 --- a/frontend/src/pages/Deploy/Deployment/List/components/DeploymentConfigModal.tsx +++ b/frontend/src/pages/Deploy/Deployment/List/components/DeploymentConfigModal.tsx @@ -1,14 +1,13 @@ import React, {useEffect, useState, useCallback} from 'react'; -import {Modal, Form, Select, message, Switch, InputNumber, Input} from 'antd'; +import {Modal, Form, Select, message, Switch, InputNumber, Input, Space, Button} from 'antd'; +import {FullscreenOutlined} from '@ant-design/icons'; import type {DeploymentConfig, DeployConfigTemplate, CreateDeploymentConfigRequest} from '../types'; 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 './styles.less'; import {Editor} from '@/components/Editor'; import type {JsonNode} from '@/types/common'; +import './styles.less'; const {Option} = Select; @@ -33,6 +32,10 @@ const DeploymentConfigModal: React.FC = ({ const [selectedTemplate, setSelectedTemplate] = useState(); const [buildVariables, setBuildVariables] = useState({}); const [loading, setLoading] = useState(false); + const [fullscreenEditor, setFullscreenEditor] = useState<{ + key: string; + title: string; + } | null>(null); const isEdit = !!initialValues?.id; // 获取应用列表 @@ -114,7 +117,7 @@ const DeploymentConfigModal: React.FC = ({ // 获取对应的模板 const template = templates.find(t => t.languageType === selectedApp.language); if (!template) { - throw new Error('未找到匹配的配置模板'); + throw new Error('未找到匹配���配置模板'); } // 构建提交数据 @@ -165,146 +168,202 @@ const DeploymentConfigModal: React.FC = ({ })); }; - // 渲染表单项 - const renderFormItems = () => { - if (!selectedTemplate?.buildVariablesSchema?.properties) return null; - - const { properties } = selectedTemplate.buildVariablesSchema; - - return ( - <> - {/* 遍历所有字段,对有 editorConfig 的字段使用富文本编辑器 */} - {Object.entries(properties).map(([key, property]) => ( - property.editorConfig ? ( - - handleEditorChange(key, value)} - options={{ - minimap: { enabled: property.editorConfig.minimap ?? false }, - fontSize: property.editorConfig.fontSize || 14, - lineNumbers: property.editorConfig.lineNumbers ? 'on' : 'off', - wordWrap: property.editorConfig.wordWrap ? 'on' : 'off', - tabSize: property.editorConfig.tabSize || 2, - scrollBeyondLastLine: false, - automaticLayout: true, - folding: property.editorConfig.folding ?? true, - autoClosingBrackets: 'always', - autoClosingQuotes: 'always', - formatOnPaste: true, - formatOnType: true, - suggestOnTriggerCharacters: property.editorConfig.autoComplete ?? true, - renderWhitespace: 'boundary', - }} - loading={ -
- 编辑器加载中... -
- } - /> -
- ) : ( - - ) => handleInputChange(key, e.target.value)} - placeholder={`请输入${property.title || key}`} - /> - - ) - ))} - - ); - }; - return ( - { - form.resetFields(); - onCancel(); - }} - onOk={handleSubmit} - width={800} - className="deployment-config-modal" - maskClosable={false} - confirmLoading={loading} - destroyOnClose - style={{ top: 50, paddingBottom: 0 }} - styles={{ - body: { - height: 'calc(100vh - 250px)', - overflowY: 'auto', - padding: '24px' - } - }} - > -
+ { + form.resetFields(); + onCancel(); + }} + onOk={handleSubmit} + width={800} + className="deployment-config-modal" + maskClosable={false} + confirmLoading={loading} + destroyOnClose + style={{ top: 50 }} + styles={{ + body: { + height: 'calc(100vh - 250px)', + overflowY: 'auto', + padding: '24px' + } }} > - {/* 应用选择 */} - - - + + - {/* 动态构建配置 */} - {renderFormItems()} + {/* 动态构建配置 */} + {selectedTemplate?.buildVariablesSchema?.properties && ( + Object.entries(selectedTemplate.buildVariablesSchema.properties).map(([key, property]) => { + if (property.editorConfig) { + return ( + + {property.title || key} +