@@ -117,13 +117,52 @@ const YamlImportSection: React.FC<YamlImportSectionProps> = ({
117117 return ;
118118 }
119119
120- if ( validateYaml ( yamlText ) ) {
121- onImportYaml ( yamlText ) ;
122- message . success ( '粘贴的YAML导入成功' ) ;
123- setIsModalVisible ( false ) ;
120+ setIsLoading ( true ) ;
121+ try {
122+ if ( validateYaml ( yamlText ) ) {
123+ onImportYaml ( yamlText ) ;
124+ message . success ( '粘贴的YAML导入成功' ) ;
125+ setIsModalVisible ( false ) ;
126+ }
127+ } finally {
128+ setIsLoading ( false ) ;
124129 }
125130 } ;
126131
132+ // 根据当前标签页渲染底部按钮
133+ const renderFooterButtons = ( ) => {
134+ const cancelButton = (
135+ < Button key = "cancel" onClick = { handleCancel } >
136+ 取消
137+ </ Button >
138+ ) ;
139+
140+ // 不同标签页的确认按钮
141+ const actionButton = activeTab === 'text' ? (
142+ < Button
143+ key = "text-import"
144+ type = "primary"
145+ onClick = { handleTextImport }
146+ loading = { isLoading }
147+ disabled = { ! yamlText . trim ( ) }
148+ >
149+ 粘贴导入
150+ </ Button >
151+ ) : (
152+ < Button
153+ key = "import"
154+ type = "primary"
155+ onClick = { handleImport }
156+ loading = { isLoading }
157+ disabled = { activeTab === 'file' }
158+ >
159+ 导入
160+ </ Button >
161+ ) ;
162+
163+ return [ cancelButton , actionButton ] ;
164+ } ;
165+
127166 // 选择当前活动的导入方式
128167 const handleImport = ( ) => {
129168 switch ( activeTab ) {
@@ -156,22 +195,7 @@ const YamlImportSection: React.FC<YamlImportSectionProps> = ({
156195 title = "导入YAML"
157196 open = { isModalVisible }
158197 onCancel = { handleCancel }
159- footer = { [
160- < Button key = "cancel" onClick = { handleCancel } >
161- 取消
162- </ Button > ,
163- activeTab !== 'text' ? (
164- < Button
165- key = "import"
166- type = "primary"
167- onClick = { handleImport }
168- loading = { isLoading }
169- disabled = { activeTab === 'file' }
170- >
171- 导入
172- </ Button >
173- ) : null
174- ] . filter ( Boolean ) }
198+ footer = { renderFooterButtons ( ) }
175199 width = { 600 }
176200 >
177201 < Tabs activeKey = { activeTab } onChange = { setActiveTab } >
@@ -196,9 +220,14 @@ const YamlImportSection: React.FC<YamlImportSectionProps> = ({
196220 </ p >
197221 < p className = "ant-upload-text" > 点击或拖拽文件到此区域上传</ p >
198222 < p className = "ant-upload-hint" >
199- 支持 .yml 或 .yaml 格式文件,包括单个挑战或包含多个挑战的集合文件(将导入第一个挑战)
223+ 支持 .yml 或 .yaml 格式文件
200224 </ p >
201225 </ Upload . Dragger >
226+ < div style = { { display : 'flex' , alignItems : 'center' , marginTop : 16 } } >
227+ < p style = { { color : '#999' , margin : 0 , flex : 1 } } >
228+ 点击或拖拽YAML文件到上方区域。支持单个挑战或包含多个挑战的集合文件(将导入第一个挑战)。
229+ </ p >
230+ </ div >
202231 </ div >
203232 </ TabPane >
204233
@@ -220,9 +249,9 @@ const YamlImportSection: React.FC<YamlImportSectionProps> = ({
220249 prefix = { < LinkOutlined /> }
221250 allowClear
222251 />
223- < div >
224- < p style = { { color : '#999' , marginTop : 8 } } >
225- 输入包含YAML内容的文件URL,点击导入按钮获取并解析内容 。
252+ < div style = { { display : 'flex' , alignItems : 'center' , marginTop : 8 } } >
253+ < p style = { { color : '#999' , margin : 0 , flex : 1 } } >
254+ 输入包含YAML内容的文件URL,点击底部的【导入】按钮获取并解析内容 。
226255 支持单个挑战或包含多个挑战的集合文件(将导入第一个挑战)。
227256 </ p >
228257 </ div >
@@ -245,23 +274,23 @@ const YamlImportSection: React.FC<YamlImportSectionProps> = ({
245274 placeholder = "粘贴YAML内容到此处"
246275 value = { yamlText }
247276 onChange = { ( e : React . ChangeEvent < HTMLTextAreaElement > ) => setYamlText ( e . target . value ) }
248- autoSize = { { minRows : 6 , maxRows : 12 } }
277+ autoSize = { { minRows : 8 , maxRows : 16 } }
278+ style = { {
279+ resize : 'none' ,
280+ backgroundColor : '#fafafa' ,
281+ border : '1px dashed #d9d9d9' ,
282+ borderRadius : '4px' ,
283+ padding : '12px'
284+ } }
249285 onPaste = { ( e : React . ClipboardEvent < HTMLTextAreaElement > ) => {
250286 console . log ( '粘贴事件触发' ) ;
251287 } }
252288 />
253- < div style = { { display : 'flex' , justifyContent : 'space-between ' , alignItems : 'center' } } >
254- < p style = { { color : '#999' , margin : '8px 0 0 0' } } >
255- 将YAML内容复制粘贴到文本框中,点击导入按钮解析内容 。
289+ < div style = { { display : 'flex' , alignItems : 'center ' , marginTop : 16 } } >
290+ < p style = { { color : '#999' , margin : 0 , flex : 1 } } >
291+ 将YAML内容复制粘贴到文本框中,点击底部的【粘贴导入】按钮解析内容 。
256292 支持单个挑战或包含多个挑战的集合文件(将导入第一个挑战)。
257293 </ p >
258- < Button
259- type = "primary"
260- onClick = { handleTextImport }
261- disabled = { ! yamlText . trim ( ) }
262- >
263- 粘贴导入
264- </ Button >
265294 </ div >
266295 </ Space >
267296 </ div >
0 commit comments