Skip to content

Commit ec6b9fb

Browse files
committed
修复YAML生成问题,保留原始格式包括标签格式和注释
1 parent 1853b25 commit ec6b9fb

File tree

5 files changed

+877
-61
lines changed

5 files changed

+877
-61
lines changed

docs/challenges/meta.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,7 @@ challenges:
9898
# 记录挑战最后修改时间,格式与create-time相同
9999
# 当任何字段变更时需同步更新此时间
100100
update-time: 2025-03-01 20:42:17
101+
102+
# 是否忽略该挑战
103+
# 设置为true时,该挑战不会在列表中显示,并且编译构建时也会忽略不会被打包
104+
ignored: true

src/components/ChallengeContributePage/components/YamlPreviewSection.tsx

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const YamlPreviewSection: React.FC<YamlPreviewSectionProps> = ({
6565
}, [yamlOutput]);
6666

6767
const showModal = () => {
68+
console.log('正在生成YAML预览,确保保留注释...');
6869
onGenerateYaml(); // 先生成YAML
6970
setIsModalVisible(true);
7071
};
@@ -237,6 +238,19 @@ const YamlPreviewSection: React.FC<YamlPreviewSectionProps> = ({
237238
>
238239
New Issue
239240
</Button>
241+
242+
{/* 调试按钮,仅在开发环境显示 */}
243+
{process.env.NODE_ENV === 'development' && (
244+
<Button
245+
onClick={() => {
246+
console.log('调试:原始YAML内容', yamlOutput);
247+
message.info('已在控制台输出调试信息');
248+
}}
249+
type="dashed"
250+
>
251+
调试
252+
</Button>
253+
)}
240254
</Space>
241255
</div>
242256

@@ -250,26 +264,25 @@ const YamlPreviewSection: React.FC<YamlPreviewSectionProps> = ({
250264
<Button key="cancel" onClick={handleCancel}>
251265
关闭
252266
</Button>,
253-
<Button key="copy" type="primary" icon={<CopyOutlined />} onClick={handleCopyAndClose}>
254-
复制
267+
<Button key="copy" type="primary" onClick={handleCopyAndClose}>
268+
复制并关闭
255269
</Button>
256270
]}
257271
>
258-
<div style={{ padding: '8px 0' }}>
259-
<SyntaxHighlighter
260-
language="yaml"
272+
<div style={{ maxHeight: '70vh', overflowY: 'auto' }}>
273+
<SyntaxHighlighter
274+
language="yaml"
261275
style={highlightTheme}
262-
customStyle={{
263-
borderRadius: '4px',
264-
fontSize: '14px',
265-
lineHeight: '1.5',
266-
maxHeight: '60vh',
267-
overflow: 'auto',
276+
customStyle={{
277+
fontSize: '14px',
278+
lineHeight: '1.5',
268279
padding: '16px',
269-
border: '1px solid #eaeaea'
280+
whiteSpace: 'pre-wrap',
281+
overflowWrap: 'break-word'
270282
}}
271283
showLineNumbers={true}
272-
wrapLongLines={true}
284+
wrapLines={true}
285+
preserveWhitespace={true}
273286
>
274287
{yamlOutput}
275288
</SyntaxHighlighter>

0 commit comments

Comments
 (0)