11import * 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' ;
44import { Light as SyntaxHighlighter } from 'react-syntax-highlighter' ;
55import yaml from 'react-syntax-highlighter/dist/esm/languages/hljs/yaml' ;
66import { vs } from 'react-syntax-highlighter/dist/esm/styles/hljs' ;
@@ -13,7 +13,7 @@ const GITHUB_REPO = 'JSREP/crawler-leetcode';
1313const GITHUB_BASE_URL = `https://github.com/${ GITHUB_REPO } ` ;
1414
1515// YAML长度限制(超过此长度需要手动提交)
16- const YAML_LENGTH_LIMIT = 1000 ;
16+ const YAML_LENGTH_LIMIT = 10000 ;
1717
1818// 自定义高亮主题
1919const highlightTheme = {
@@ -40,6 +40,7 @@ const YamlPreviewSection: React.FC<YamlPreviewSectionProps> = ({
4040} ) => {
4141 const [ isModalVisible , setIsModalVisible ] = React . useState < boolean > ( false ) ;
4242 const [ isLengthWarningVisible , setIsLengthWarningVisible ] = React . useState < boolean > ( false ) ;
43+ const [ isPrGuideVisible , setIsPrGuideVisible ] = React . useState < boolean > ( false ) ;
4344 const [ currentAction , setCurrentAction ] = React . useState < 'PR' | 'Issue' | null > ( null ) ;
4445 const [ pendingAction , setPendingAction ] = React . useState < 'PR' | 'Issue' | null > ( null ) ;
4546
@@ -153,22 +154,10 @@ const YamlPreviewSection: React.FC<YamlPreviewSectionProps> = ({
153154 // 使用navigator.clipboard API复制YAML到剪贴板
154155 navigator . clipboard . writeText ( yamlOutput )
155156 . 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已复制到剪贴板' ) ;
166158
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 ) ;
172161 } )
173162 . catch ( ( error ) => {
174163 console . error ( '复制YAML失败:' , error ) ;
@@ -218,6 +207,11 @@ const YamlPreviewSection: React.FC<YamlPreviewSectionProps> = ({
218207 checkYamlLengthAndProceed ( 'Issue' ) ;
219208 } ;
220209
210+ // 关闭PR引导弹窗
211+ const handlePrGuideCancel = ( ) => {
212+ setIsPrGuideVisible ( false ) ;
213+ } ;
214+
221215 return (
222216 < >
223217 { /* 显示操作按钮 */ }
@@ -308,6 +302,38 @@ const YamlPreviewSection: React.FC<YamlPreviewSectionProps> = ({
308302 </ ol >
309303 </ div >
310304 </ 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 >
311337 </ >
312338 ) ;
313339} ;
0 commit comments