blob: ec5161bd9c21c37c88fa05e49090f1c73bd73e9b [file] [log] [blame]
刘嘉昕34401cc2025-06-09 22:47:33 +08001import React, { useEffect, useState } from 'react';
2import ReactMarkdown from 'react-markdown';
3import remarkGfm from 'remark-gfm';
4import rehypeHighlight from 'rehype-highlight';
5import './HelpPage.css'; // 引入样式
6import Navbar from '../components/Navbar'; // 导航栏组件
7
8export default function HelpPage() {
9 const [markdown, setMarkdown] = useState('');
10
11 useEffect(() => {
12 fetch('/help.md')
13 .then(res => {
14 if (!res.ok) throw new Error('Markdown 文件加载失败');
15 return res.text();
16 })
17 .then(text => setMarkdown(text))
18 .catch(() => setMarkdown('# 帮助文档加载失败,请稍后再试。'));
19 }, []);
20
21 return (
22 <div>
23 <Navbar />
24 <div className="help-page-wrapper">
25 <div className="help-container">
26 <h1 className="help-title">📚 帮助文档</h1>
27 <div className="help-content">
28 <ReactMarkdown
29 remarkPlugins={[remarkGfm]}
30 rehypePlugins={[rehypeHighlight]}
31 components={{
32 h1: ({ node, ...props }) => <h1 {...props} />,
33 h2: ({ node, ...props }) => <h2 {...props} />,
34 p: ({ node, ...props }) => <p {...props} />,
35 code: ({ node, ...props }) => <code {...props} />,
36 pre: ({ node, ...props }) => <pre {...props} />,
37 blockquote: ({ node, ...props }) => <blockquote {...props} />,
38 }}
39 >
40 {markdown}
41 </ReactMarkdown>
42 </div>
43 </div>
44 </div>
45 </div>
46 );
47}