64 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-03-13 14:40:38 +08:00
import type { RouteObject } from 'react-router-dom'
import { useRoutes } from 'react-router-dom'
2022-05-12 02:45:43 +08:00
import Album from '@/web/pages/Album'
import Home from '@/web/pages/Home'
import Login from '@/web/pages/Login'
import Playlist from '@/web/pages/Playlist'
import Artist from '@/web/pages/Artist'
import Search from '@/web/pages/Search'
import Library from '@/web/pages/Library'
import Podcast from '@/web/pages/Podcast'
import Settings from '@/web/pages/Settings'
2022-03-13 14:40:38 +08:00
const routes: RouteObject[] = [
{
path: '/',
element: <Home />,
},
2022-04-05 02:32:13 +08:00
{
path: '/podcast',
element: <Podcast />,
},
2022-04-04 17:51:07 +08:00
{
path: '/library',
element: <Library />,
},
2022-04-05 02:32:13 +08:00
{
path: '/settings',
element: <Settings />,
},
2022-03-13 14:40:38 +08:00
{
path: '/login',
element: <Login />,
},
2022-03-29 00:11:05 +08:00
{
path: '/search/:keywords',
element: <Search />,
children: [
{
path: ':type',
element: <Search />,
},
],
},
2022-03-13 14:40:38 +08:00
{
path: '/playlist/:id',
element: <Playlist />,
},
{
path: '/album/:id',
element: <Album />,
},
2022-03-23 01:21:22 +08:00
{
path: '/artist/:id',
element: <Artist />,
},
2022-03-13 14:40:38 +08:00
]
2022-03-23 01:21:22 +08:00
const Router = () => {
2022-03-13 14:40:38 +08:00
const element = useRoutes(routes)
2022-03-29 00:11:05 +08:00
return <>{element}</>
2022-03-13 14:40:38 +08:00
}
2022-03-23 01:21:22 +08:00
export default Router