2024-10-13 17:37:01 +00:00
|
|
|
import type { Route } from '@/router'
|
|
|
|
import Router from '@/router'
|
2022-10-08 10:54:25 +00:00
|
|
|
import { userStore } from '@/stores'
|
2024-01-22 23:16:57 +00:00
|
|
|
import { cache, playlistCollaborationService } from '@/services'
|
2024-01-04 11:35:36 +00:00
|
|
|
import { useUpload } from '@/composables'
|
2024-01-22 23:16:57 +00:00
|
|
|
import { logger } from '@/utils'
|
2024-01-18 11:13:05 +00:00
|
|
|
|
|
|
|
const UUID_REGEX = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
|
2022-10-08 10:54:25 +00:00
|
|
|
|
|
|
|
export const routes: Route[] = [
|
|
|
|
{
|
|
|
|
path: '/home',
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'Home',
|
2022-10-08 10:54:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/404',
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: '404',
|
2022-10-08 10:54:25 +00:00
|
|
|
},
|
2022-10-08 11:57:54 +00:00
|
|
|
{
|
|
|
|
path: '/queue',
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'Queue',
|
2022-10-08 11:57:54 +00:00
|
|
|
},
|
2022-10-08 10:54:25 +00:00
|
|
|
{
|
|
|
|
path: '/songs',
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'Songs',
|
2022-10-08 10:54:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/albums',
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'Albums',
|
2022-10-08 10:54:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/artists',
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'Artists',
|
2022-10-08 10:54:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/favorites',
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'Favorites',
|
2022-10-08 10:54:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/recently-played',
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'RecentlyPlayed',
|
2022-10-08 10:54:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/search',
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'Search.Excerpt',
|
2022-10-08 10:54:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/search/songs',
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'Search.Songs',
|
2022-10-08 10:54:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/upload',
|
|
|
|
screen: 'Upload',
|
2024-10-13 17:37:01 +00:00
|
|
|
onResolve: () => useUpload().allowsUpload.value,
|
2022-10-08 10:54:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/settings',
|
|
|
|
screen: 'Settings',
|
2024-10-13 17:37:01 +00:00
|
|
|
onResolve: () => userStore.current?.is_admin,
|
2022-10-08 10:54:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/users',
|
|
|
|
screen: 'Users',
|
2024-10-13 17:37:01 +00:00
|
|
|
onResolve: () => userStore.current?.is_admin,
|
2022-10-08 10:54:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/youtube',
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'YouTube',
|
2022-10-08 10:54:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/profile',
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'Profile',
|
2022-10-08 10:54:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'visualizer',
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'Visualizer',
|
2022-10-08 10:54:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/album/(?<id>\\d+)',
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'Album',
|
2022-10-08 10:54:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/artist/(?<id>\\d+)',
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'Artist',
|
2022-10-08 10:54:25 +00:00
|
|
|
},
|
|
|
|
{
|
2024-01-18 11:13:05 +00:00
|
|
|
path: `/playlist/(?<id>${UUID_REGEX})`,
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'Playlist',
|
2022-10-08 10:54:25 +00:00
|
|
|
},
|
2024-01-18 11:13:05 +00:00
|
|
|
{
|
|
|
|
path: `/playlist/collaborate/(?<id>${UUID_REGEX})`,
|
|
|
|
screen: 'Blank',
|
|
|
|
onResolve: async params => {
|
|
|
|
try {
|
|
|
|
const playlist = await playlistCollaborationService.acceptInvite(params.id)
|
|
|
|
Router.go(`/playlist/${playlist.id}`, true)
|
|
|
|
return true
|
2024-04-23 11:24:29 +00:00
|
|
|
} catch (error: unknown) {
|
|
|
|
logger.error(error)
|
2024-01-18 11:13:05 +00:00
|
|
|
return false
|
|
|
|
}
|
2024-10-13 17:37:01 +00:00
|
|
|
},
|
2024-01-18 11:13:05 +00:00
|
|
|
},
|
2022-10-21 20:06:43 +00:00
|
|
|
{
|
|
|
|
path: '/genres',
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'Genres',
|
2022-10-21 20:06:43 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/genres/(?<name>\.+)',
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'Genre',
|
2022-10-21 20:06:43 +00:00
|
|
|
},
|
2024-05-19 05:49:42 +00:00
|
|
|
{
|
|
|
|
path: '/podcasts',
|
|
|
|
screen: 'Podcasts',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: `/podcasts/(?<id>${UUID_REGEX})`,
|
|
|
|
screen: 'Podcast',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/episodes/(?<id>\.+)',
|
|
|
|
screen: 'Episode',
|
|
|
|
},
|
2022-11-06 17:09:06 +00:00
|
|
|
{
|
|
|
|
path: '/visualizer',
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'Visualizer',
|
2022-11-06 17:09:06 +00:00
|
|
|
},
|
2022-10-08 10:54:25 +00:00
|
|
|
{
|
2024-01-18 11:13:05 +00:00
|
|
|
path: `/song/(?<id>${UUID_REGEX})`,
|
2022-10-08 10:54:25 +00:00
|
|
|
screen: 'Queue',
|
2022-10-08 11:57:54 +00:00
|
|
|
redirect: () => 'queue',
|
2024-01-11 19:26:38 +00:00
|
|
|
onResolve: params => {
|
2024-01-22 23:16:57 +00:00
|
|
|
cache.set('song-to-queue', params.id)
|
2024-01-11 19:26:38 +00:00
|
|
|
return true
|
2024-10-13 17:37:01 +00:00
|
|
|
},
|
2023-08-20 22:35:58 +00:00
|
|
|
},
|
|
|
|
{
|
2024-01-18 11:13:05 +00:00
|
|
|
path: `/invitation/accept/(?<token>${UUID_REGEX})`,
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'Invitation.Accept',
|
2024-02-25 19:32:53 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: `/reset-password/(?<payload>[a-zA-Z0-9\\+/=]+)`,
|
2024-10-13 17:37:01 +00:00
|
|
|
screen: 'Password.Reset',
|
|
|
|
},
|
2022-10-08 10:54:25 +00:00
|
|
|
]
|