@@ -52,6 +52,7 @@ export const VideoRow = function ({title, videos, ...props}) {
5252 }
5353
5454 function openModal ( video ) {
55+ window . location . hash = video . title
5556 setCurrVideo ( video )
5657 setIsOpen ( true ) ;
5758 }
@@ -61,7 +62,9 @@ export const VideoRow = function ({title, videos, ...props}) {
6162 // subtitle.style.color = '#f00';
6263 }
6364
64- function closeModal ( ) {
65+ function closeModal ( ) {
66+ window . location . hash = ''
67+
6568 let player = videojs . getPlayer ( 'my-video' )
6669 if ( player ) {
6770 player . pause ( )
@@ -70,6 +73,22 @@ export const VideoRow = function ({title, videos, ...props}) {
7073 }
7174 }
7275
76+ useEffect ( ( ) => {
77+ let timer
78+ timer = setTimeout ( ( ) => {
79+ if ( window . location . hash ) {
80+ let title = decodeURI ( window . location . hash . slice ( 1 , window . location . hash . length ) )
81+ const video = videos . find ( video => video . title === title )
82+ if ( video ) {
83+ console . log ( 'find video:' , title , video )
84+ openModal ( video )
85+ }
86+ }
87+ } , 800 )
88+
89+ return ( ) => clearTimeout ( timer )
90+ } , [ ] )
91+
7392 useLayoutEffect ( ( ) => {
7493 const observer = window . lozad ( '.lozad' , {
7594 load : ( el ) => {
@@ -167,6 +186,7 @@ function Projects() {
167186 {
168187 tags . map ( tag => (
169188 < button
189+ key = { tag }
170190 className = { clsx ( styles . tag , currentTag === tag && styles . tagActive ) }
171191 onClick = { ( ) => setCurrentTag ( tag ) }
172192 >
0 commit comments