@@ -5,6 +5,7 @@ import styles from './Header.module.css'
55
66export function Header ( { title, leetcodeUrl, githubUrl } : HeaderProps ) {
77 const [ stars , setStars ] = useState < number > ( 0 )
8+ const [ showVideo , setShowVideo ] = useState ( false )
89
910 useEffect ( ( ) => {
1011 // 从GitHub URL中提取owner和repo
@@ -15,39 +16,82 @@ export function Header({ title, leetcodeUrl, githubUrl }: HeaderProps) {
1516 }
1617 } , [ githubUrl ] )
1718
19+ // 关闭模态框时停止视频播放
20+ const handleCloseModal = ( ) => {
21+ setShowVideo ( false )
22+ }
23+
1824 return (
19- < header className = { styles . header } >
20- < a
21- href = { leetcodeUrl }
22- target = "_blank"
23- rel = "noopener noreferrer"
24- className = { styles . title }
25- >
26- { title }
27- </ a >
28- < a
29- href = { githubUrl }
30- target = "_blank"
31- rel = "noopener noreferrer"
32- className = { styles . github }
33- aria-label = "GitHub 仓库"
34- title = "点击去GitHub仓库Star支持一下"
35- >
36- < svg
37- viewBox = "0 0 24 24"
38- width = "24"
39- height = "24"
40- fill = "currentColor"
25+ < >
26+ < header className = { styles . header } >
27+ < a
28+ href = { leetcodeUrl }
29+ target = "_blank"
30+ rel = "noopener noreferrer"
31+ className = { styles . title }
4132 >
42- < path d = "M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z" />
43- </ svg >
44- < span className = { styles . starCount } >
45- < svg viewBox = "0 0 16 16" width = "14" height = "14" fill = "currentColor" >
46- < path d = "M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25z" />
47- </ svg >
48- { stars }
49- </ span >
50- </ a >
51- </ header >
33+ { title }
34+ </ a >
35+ < div className = { styles . rightSection } >
36+ < button
37+ className = { styles . videoButton }
38+ onClick = { ( ) => setShowVideo ( true ) }
39+ aria-label = "观看讲解视频"
40+ title = "观看讲解视频"
41+ >
42+ < svg viewBox = "0 0 24 24" width = "18" height = "18" fill = "currentColor" >
43+ < path d = "M8 5v14l11-7z" />
44+ </ svg >
45+ 讲解视频
46+ </ button >
47+ < a
48+ href = { githubUrl }
49+ target = "_blank"
50+ rel = "noopener noreferrer"
51+ className = { styles . github }
52+ aria-label = "GitHub 仓库"
53+ title = "点击去GitHub仓库Star支持一下"
54+ >
55+ < svg
56+ viewBox = "0 0 24 24"
57+ width = "24"
58+ height = "24"
59+ fill = "currentColor"
60+ >
61+ < path d = "M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z" />
62+ </ svg >
63+ < span className = { styles . starCount } >
64+ < svg viewBox = "0 0 16 16" width = "14" height = "14" fill = "currentColor" >
65+ < path d = "M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25z" />
66+ </ svg >
67+ { stars }
68+ </ span >
69+ </ a >
70+ </ div >
71+ </ header >
72+
73+ { /* 视频模态框 */ }
74+ { showVideo && (
75+ < div className = { styles . modalOverlay } onClick = { handleCloseModal } >
76+ < div className = { styles . modalContent } onClick = { ( e ) => e . stopPropagation ( ) } >
77+ < button
78+ className = { styles . closeButton }
79+ onClick = { handleCloseModal }
80+ aria-label = "关闭视频"
81+ >
82+ ✕
83+ </ button >
84+ < video
85+ className = { styles . video }
86+ controls
87+ autoPlay
88+ src = "/video.mp4"
89+ >
90+ 您的浏览器不支持视频播放
91+ </ video >
92+ </ div >
93+ </ div >
94+ ) }
95+ </ >
5296 )
5397}
0 commit comments