40 lines
1.5 KiB
TypeScript
Raw Normal View History

2022-10-28 20:29:04 +08:00
import { Route, Routes, useLocation } from 'react-router-dom'
import { AnimatePresence } from 'framer-motion'
2023-03-26 02:16:01 +08:00
import React, { lazy, Suspense } from 'react'
2023-01-07 14:39:03 +08:00
import VideoPlayer from './VideoPlayer'
2022-03-13 14:40:38 +08:00
2023-03-26 02:16:01 +08:00
const My = lazy(() => import('@/web/pages/My'))
const Discover = lazy(() => import('@/web/pages/Discover'))
const Browse = lazy(() => import('@/web/pages/Browse'))
const Album = lazy(() => import('@/web/pages/Album'))
const Playlist = lazy(() => import('@/web/pages/Playlist'))
const Artist = lazy(() => import('@/web/pages/Artist'))
const Lyrics = lazy(() => import('@/web/pages/Lyrics'))
const Search = lazy(() => import('@/web/pages/Search'))
const Settings = lazy(() => import('@/web/pages/Settings'))
2022-03-13 14:40:38 +08:00
2022-03-23 01:21:22 +08:00
const Router = () => {
2022-10-28 20:29:04 +08:00
const location = useLocation()
return (
2023-01-07 14:39:03 +08:00
<AnimatePresence mode='wait'>
<VideoPlayer />
2022-10-28 20:29:04 +08:00
<Routes location={location} key={location.pathname}>
2023-03-26 02:16:01 +08:00
<Route path='/' element={<My />} />
<Route path='/discover' element={<Discover />} />
<Route path='/browse' element={<Browse />} />
<Route path='/album/:id' element={<Album />} />
<Route path='/playlist/:id' element={<Playlist />} />
<Route path='/artist/:id' element={<Artist />} />
<Route path='/settings' element={<Settings />} />
<Route path='/lyrics' element={<Lyrics />} />
<Route path='/search/:keywords' element={<Search />}>
<Route path=':type' element={<Search />} />
2022-10-28 20:29:04 +08:00
</Route>
</Routes>
</AnimatePresence>
)
2022-03-13 14:40:38 +08:00
}
2022-03-23 01:21:22 +08:00
export default Router