1
1
import * as React from 'react' ;
2
- import { Button , Modal , Space , message } from 'antd' ;
3
- import { CopyOutlined , GithubOutlined } from '@ant-design/icons' ;
2
+ import { Button , Modal , Space , message , Typography } from 'antd' ;
3
+ import { CopyOutlined , GithubOutlined , QuestionCircleOutlined } from '@ant-design/icons' ;
4
4
import { Light as SyntaxHighlighter } from 'react-syntax-highlighter' ;
5
5
import yaml from 'react-syntax-highlighter/dist/esm/languages/hljs/yaml' ;
6
6
import { vs } from 'react-syntax-highlighter/dist/esm/styles/hljs' ;
@@ -13,7 +13,7 @@ const GITHUB_REPO = 'JSREP/crawler-leetcode';
13
13
const GITHUB_BASE_URL = `https://github.com/${ GITHUB_REPO } ` ;
14
14
15
15
// YAML长度限制(超过此长度需要手动提交)
16
- const YAML_LENGTH_LIMIT = 1000 ;
16
+ const YAML_LENGTH_LIMIT = 10000 ;
17
17
18
18
// 自定义高亮主题
19
19
const highlightTheme = {
@@ -40,6 +40,7 @@ const YamlPreviewSection: React.FC<YamlPreviewSectionProps> = ({
40
40
} ) => {
41
41
const [ isModalVisible , setIsModalVisible ] = React . useState < boolean > ( false ) ;
42
42
const [ isLengthWarningVisible , setIsLengthWarningVisible ] = React . useState < boolean > ( false ) ;
43
+ const [ isPrGuideVisible , setIsPrGuideVisible ] = React . useState < boolean > ( false ) ;
43
44
const [ currentAction , setCurrentAction ] = React . useState < 'PR' | 'Issue' | null > ( null ) ;
44
45
const [ pendingAction , setPendingAction ] = React . useState < 'PR' | 'Issue' | null > ( null ) ;
45
46
@@ -153,22 +154,10 @@ const YamlPreviewSection: React.FC<YamlPreviewSectionProps> = ({
153
154
// 使用navigator.clipboard API复制YAML到剪贴板
154
155
navigator . clipboard . writeText ( yamlOutput )
155
156
. then ( ( ) => {
156
- message . success ( 'YAML已复制到剪贴板,请在GitHub中粘贴' ) ;
157
-
158
- // 准备PR标题和基本说明
159
- const title = encodeURIComponent ( `新增题目: ${ challengeName } ` ) ;
160
- const body = encodeURIComponent (
161
- `## 新增题目\n\n` +
162
- `提交一个新的挑战题目。\n\n` +
163
- `### YAML代码\n\n` +
164
- `\`\`\`yaml\n${ yamlOutput } \n\`\`\``
165
- ) ;
157
+ message . success ( 'YAML已复制到剪贴板' ) ;
166
158
167
- // 构建PR创建URL
168
- const prUrl = `${ GITHUB_BASE_URL } /compare/main...?quick_pull=1&title=${ title } &body=${ body } ` ;
169
-
170
- // 在新标签页中打开
171
- window . open ( prUrl , '_blank' ) ;
159
+ // 显示PR引导弹窗
160
+ setIsPrGuideVisible ( true ) ;
172
161
} )
173
162
. catch ( ( error ) => {
174
163
console . error ( '复制YAML失败:' , error ) ;
@@ -218,6 +207,11 @@ const YamlPreviewSection: React.FC<YamlPreviewSectionProps> = ({
218
207
checkYamlLengthAndProceed ( 'Issue' ) ;
219
208
} ;
220
209
210
+ // 关闭PR引导弹窗
211
+ const handlePrGuideCancel = ( ) => {
212
+ setIsPrGuideVisible ( false ) ;
213
+ } ;
214
+
221
215
return (
222
216
< >
223
217
{ /* 显示操作按钮 */ }
@@ -308,6 +302,38 @@ const YamlPreviewSection: React.FC<YamlPreviewSectionProps> = ({
308
302
</ ol >
309
303
</ div >
310
304
</ Modal >
305
+
306
+ { /* PR引导对话框 */ }
307
+ < Modal
308
+ title = "如何提交Pull Request"
309
+ open = { isPrGuideVisible }
310
+ onCancel = { handlePrGuideCancel }
311
+ footer = { [
312
+ < Button key = "close" onClick = { handlePrGuideCancel } >
313
+ 关闭
314
+ </ Button > ,
315
+ ] }
316
+ >
317
+ < div style = { { padding : '16px 0' } } >
318
+ < Typography . Title level = { 5 } > 提交Pull Request的步骤</ Typography . Title >
319
+ < ol style = { { paddingLeft : '20px' } } >
320
+ < li > 访问项目仓库:< Typography . Link href = { GITHUB_BASE_URL } target = "_blank" > { GITHUB_BASE_URL } </ Typography . Link > </ li >
321
+ < li > 点击仓库页面右上角的"Fork"按钮创建自己的分支</ li >
322
+ < li > 在Fork后的仓库中,创建一个新的分支</ li >
323
+ < li > 在新分支中,导航到challenges文件夹</ li >
324
+ < li > 点击"Add file" > "Create new file"</ li >
325
+ < li > 为文件命名,格式为:challenges/[题目ID].yaml</ li >
326
+ < li > 将已复制的YAML内容粘贴到文件编辑器中</ li >
327
+ < li > 点击"Commit new file"提交更改</ li >
328
+ < li > 回到仓库主页,点击"Pull requests" > "New pull request"</ li >
329
+ < li > 确认更改并点击"Create pull request"</ li >
330
+ < li > 填写PR标题和描述,然后点击"Create pull request"完成提交</ li >
331
+ </ ol >
332
+ < Typography . Paragraph >
333
+ < QuestionCircleOutlined /> 提示:YAML内容已自动复制到剪贴板,您可以直接粘贴。
334
+ </ Typography . Paragraph >
335
+ </ div >
336
+ </ Modal >
311
337
</ >
312
338
) ;
313
339
} ;
0 commit comments