Skip to content

Commit

Permalink
feat: use pathname to load lyric
Browse files Browse the repository at this point in the history
  • Loading branch information
harukiinharu committed Dec 9, 2024
1 parent dc8d64b commit 5e80d90
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ const App: React.FC = () => {
const audioRef = useRef<HTMLAudioElement>(null)

useEffect(() => {
const params = new URLSearchParams(window.location.search)
const lyricName = params.get('name') || '少年少女'
const lyricName = window.location.pathname.split('/')[1] || '少年少女'

fetch(`./lyric/${lyricName}.json`)
.then(res => res.json())
Expand All @@ -20,7 +19,7 @@ const App: React.FC = () => {
setLyricData({ lyricTime, lyricJson })
})
.catch(error => {
console.error('Error loading lyrics:', error)
console.error(`Error: lyric not found: ${lyricName}`)
})

if (audioRef.current) {
Expand Down

0 comments on commit 5e80d90

Please sign in to comment.