@@ -117,13 +117,52 @@ const YamlImportSection: React.FC<YamlImportSectionProps> = ({
117
117
return ;
118
118
}
119
119
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 ) ;
124
129
}
125
130
} ;
126
131
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
+
127
166
// 选择当前活动的导入方式
128
167
const handleImport = ( ) => {
129
168
switch ( activeTab ) {
@@ -156,22 +195,7 @@ const YamlImportSection: React.FC<YamlImportSectionProps> = ({
156
195
title = "导入YAML"
157
196
open = { isModalVisible }
158
197
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 ( ) }
175
199
width = { 600 }
176
200
>
177
201
< Tabs activeKey = { activeTab } onChange = { setActiveTab } >
@@ -196,9 +220,14 @@ const YamlImportSection: React.FC<YamlImportSectionProps> = ({
196
220
</ p >
197
221
< p className = "ant-upload-text" > 点击或拖拽文件到此区域上传</ p >
198
222
< p className = "ant-upload-hint" >
199
- 支持 .yml 或 .yaml 格式文件,包括单个挑战或包含多个挑战的集合文件(将导入第一个挑战)
223
+ 支持 .yml 或 .yaml 格式文件
200
224
</ p >
201
225
</ 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 >
202
231
</ div >
203
232
</ TabPane >
204
233
@@ -220,9 +249,9 @@ const YamlImportSection: React.FC<YamlImportSectionProps> = ({
220
249
prefix = { < LinkOutlined /> }
221
250
allowClear
222
251
/>
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,点击底部的【导入】按钮获取并解析内容 。
226
255
支持单个挑战或包含多个挑战的集合文件(将导入第一个挑战)。
227
256
</ p >
228
257
</ div >
@@ -245,23 +274,23 @@ const YamlImportSection: React.FC<YamlImportSectionProps> = ({
245
274
placeholder = "粘贴YAML内容到此处"
246
275
value = { yamlText }
247
276
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
+ } }
249
285
onPaste = { ( e : React . ClipboardEvent < HTMLTextAreaElement > ) => {
250
286
console . log ( '粘贴事件触发' ) ;
251
287
} }
252
288
/>
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内容复制粘贴到文本框中,点击底部的【粘贴导入】按钮解析内容 。
256
292
支持单个挑战或包含多个挑战的集合文件(将导入第一个挑战)。
257
293
</ p >
258
- < Button
259
- type = "primary"
260
- onClick = { handleTextImport }
261
- disabled = { ! yamlText . trim ( ) }
262
- >
263
- 粘贴导入
264
- </ Button >
265
294
</ div >
266
295
</ Space >
267
296
</ div >
0 commit comments