2023-07-10 03:52:52 -04:00
|
|
|
import * as types from '@/store/mutation_types'
|
2022-02-19 00:18:01 -05:00
|
|
|
import { createRouter, createWebHashHistory } from 'vue-router'
|
2023-07-10 04:37:45 -04:00
|
|
|
import PageAbout from '@/pages/PageAbout.vue'
|
2023-07-10 14:33:07 -04:00
|
|
|
import PageAlbum from '@/pages/PageAlbum.vue'
|
2023-07-12 15:30:52 -04:00
|
|
|
import PageAlbumSpotify from '@/pages/PageAlbumSpotify.vue'
|
2023-07-10 14:33:07 -04:00
|
|
|
import PageAlbums from '@/pages/PageAlbums.vue'
|
|
|
|
import PageArtist from '@/pages/PageArtist.vue'
|
2023-07-12 15:30:52 -04:00
|
|
|
import PageArtistSpotify from '@/pages/PageArtistSpotify.vue'
|
2023-07-10 14:33:07 -04:00
|
|
|
import PageArtistTracks from '@/pages/PageArtistTracks.vue'
|
|
|
|
import PageArtists from '@/pages/PageArtists.vue'
|
2023-07-10 03:52:52 -04:00
|
|
|
import PageAudiobooksAlbum from '@/pages/PageAudiobooksAlbum.vue'
|
|
|
|
import PageAudiobooksAlbums from '@/pages/PageAudiobooksAlbums.vue'
|
2023-07-10 14:33:07 -04:00
|
|
|
import PageAudiobooksArtist from '@/pages/PageAudiobooksArtist.vue'
|
|
|
|
import PageAudiobooksArtists from '@/pages/PageAudiobooksArtists.vue'
|
2023-07-12 11:47:16 -04:00
|
|
|
import PageBrowse from '@/pages/PageBrowse.vue'
|
|
|
|
import PageBrowseRecentlyAdded from '@/pages/PageBrowseRecentlyAdded.vue'
|
|
|
|
import PageBrowseRecentlyPlayed from '@/pages/PageBrowseRecentlyPlayed.vue'
|
2023-07-12 15:30:52 -04:00
|
|
|
import PageBrowseSpotify from '@/pages/PageBrowseSpotify.vue'
|
|
|
|
import PageBrowseSpotifyNewReleases from '@/pages/PageBrowseSpotifyNewReleases.vue'
|
|
|
|
import PageBrowseSpotifyFeaturedPlaylists from '@/pages/PageBrowseSpotifyFeaturedPlaylists.vue'
|
2023-07-12 17:02:02 -04:00
|
|
|
import PageComposerAlbums from '@/pages/PageComposerAlbums.vue'
|
|
|
|
import PageComposerTracks from '@/pages/PageComposerTracks.vue'
|
|
|
|
import PageComposers from '@/pages/PageComposers.vue'
|
2023-07-10 07:24:42 -04:00
|
|
|
import PageFiles from '@/pages/PageFiles.vue'
|
2023-07-10 14:54:52 -04:00
|
|
|
import PageGenre from '@/pages/PageGenre.vue'
|
|
|
|
import PageGenreTracks from '@/pages/PageGenreTracks.vue'
|
|
|
|
import PageGenres from '@/pages/PageGenres.vue'
|
2023-07-10 09:37:40 -04:00
|
|
|
import PagePlaylist from '@/pages/PagePlaylist.vue'
|
|
|
|
import PagePlaylistSpotify from '@/pages/PagePlaylistSpotify.vue'
|
|
|
|
import PagePlaylistTracks from '@/pages/PagePlaylistTracks.vue'
|
2023-07-10 07:09:27 -04:00
|
|
|
import PagePodcast from '@/pages/PagePodcast.vue'
|
|
|
|
import PagePodcasts from '@/pages/PagePodcasts.vue'
|
2022-02-19 00:18:01 -05:00
|
|
|
import PageNowPlaying from '@/pages/PageNowPlaying.vue'
|
2023-07-10 07:09:27 -04:00
|
|
|
import PageQueue from '@/pages/PageQueue.vue'
|
2023-07-11 03:51:17 -04:00
|
|
|
import PageSettingsWebinterface from '@/pages/PageSettingsWebinterface.vue'
|
|
|
|
import PageSettingsArtwork from '@/pages/PageSettingsArtwork.vue'
|
|
|
|
import PageSettingsOnlineServices from '@/pages/PageSettingsOnlineServices.vue'
|
|
|
|
import PageSettingsRemotesOutputs from '@/pages/PageSettingsRemotesOutputs.vue'
|
2022-02-19 00:18:01 -05:00
|
|
|
import PageRadioStreams from '@/pages/PageRadioStreams.vue'
|
2023-07-10 06:10:39 -04:00
|
|
|
import PageSearchLibrary from '@/pages/PageSearchLibrary.vue'
|
2023-07-10 07:58:26 -04:00
|
|
|
import PageSearchSpotify from '@/pages/PageSearchSpotify.vue'
|
2023-07-10 04:37:45 -04:00
|
|
|
import store from '@/store'
|
2018-08-11 01:47:10 -04:00
|
|
|
|
2022-02-19 00:18:01 -05:00
|
|
|
export const router = createRouter({
|
|
|
|
history: createWebHashHistory(),
|
2018-08-11 01:47:10 -04:00
|
|
|
routes: [
|
2023-07-10 04:37:45 -04:00
|
|
|
{
|
|
|
|
component: PageAbout,
|
|
|
|
name: 'about',
|
|
|
|
path: '/about'
|
|
|
|
},
|
2023-07-10 14:43:10 -04:00
|
|
|
{
|
|
|
|
component: PageAlbum,
|
|
|
|
meta: { show_progress: true },
|
|
|
|
name: 'music-album',
|
|
|
|
path: '/music/albums/:id'
|
|
|
|
},
|
2023-07-12 15:30:52 -04:00
|
|
|
{
|
|
|
|
component: PageAlbumSpotify,
|
|
|
|
meta: { show_progress: true },
|
|
|
|
name: 'music-spotify-album',
|
|
|
|
path: '/music/spotify/albums/:id'
|
|
|
|
},
|
2023-07-10 14:43:10 -04:00
|
|
|
{
|
|
|
|
component: PageAlbums,
|
|
|
|
meta: { has_index: true, has_tabs: true, show_progress: true },
|
|
|
|
name: 'music-albums',
|
|
|
|
path: '/music/albums'
|
|
|
|
},
|
2023-07-10 14:33:07 -04:00
|
|
|
{
|
|
|
|
component: PageArtist,
|
|
|
|
meta: { show_progress: true, has_index: true },
|
|
|
|
name: 'music-artist',
|
|
|
|
path: '/music/artists/:id'
|
|
|
|
},
|
2023-07-12 15:30:52 -04:00
|
|
|
{
|
|
|
|
component: PageArtistSpotify,
|
|
|
|
meta: { show_progress: true },
|
|
|
|
name: 'music-spotify-artist',
|
|
|
|
path: '/music/spotify/artists/:id'
|
|
|
|
},
|
2023-07-10 14:33:07 -04:00
|
|
|
{
|
|
|
|
component: PageArtists,
|
|
|
|
meta: { has_index: true, has_tabs: true, show_progress: true },
|
|
|
|
name: 'music-artists',
|
|
|
|
path: '/music/artists'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PageArtistTracks,
|
|
|
|
meta: { has_index: true, show_progress: true },
|
|
|
|
name: 'music-artist-tracks',
|
|
|
|
path: '/music/artists/:id/tracks'
|
|
|
|
},
|
2023-07-10 03:52:52 -04:00
|
|
|
{
|
|
|
|
component: PageAudiobooksAlbum,
|
|
|
|
meta: { show_progress: true },
|
2023-07-10 14:08:35 -04:00
|
|
|
name: 'audiobooks-album',
|
2023-07-10 14:33:07 -04:00
|
|
|
path: '/audiobooks/albums/:id'
|
2023-07-10 14:08:35 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PageAudiobooksAlbums,
|
|
|
|
meta: { has_index: true, has_tabs: true, show_progress: true },
|
|
|
|
name: 'audiobooks-albums',
|
|
|
|
path: '/audiobooks/albums'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PageAudiobooksArtist,
|
|
|
|
meta: { show_progress: true },
|
|
|
|
name: 'audiobooks-artist',
|
2023-07-10 14:33:07 -04:00
|
|
|
path: '/audiobooks/artists/:id'
|
2023-07-10 14:08:35 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PageAudiobooksArtists,
|
|
|
|
meta: { has_index: true, has_tabs: true, show_progress: true },
|
|
|
|
name: 'audiobooks-artists',
|
|
|
|
path: '/audiobooks/artists'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'audiobooks',
|
|
|
|
path: '/audiobooks',
|
|
|
|
redirect: '/audiobooks/artists'
|
2023-07-10 03:52:52 -04:00
|
|
|
},
|
2018-08-11 01:47:10 -04:00
|
|
|
{
|
2023-07-12 11:25:47 -04:00
|
|
|
name: 'music',
|
2018-08-11 01:47:10 -04:00
|
|
|
path: '/music',
|
|
|
|
redirect: '/music/browse'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PageBrowse,
|
2023-07-12 11:47:16 -04:00
|
|
|
meta: { has_tabs: true, show_progress: true },
|
|
|
|
name: 'music-browse',
|
|
|
|
path: '/music/browse'
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PageBrowseRecentlyAdded,
|
2023-07-12 11:47:16 -04:00
|
|
|
meta: { has_tabs: true, show_progress: true },
|
|
|
|
name: 'music-browse-recently-added',
|
|
|
|
path: '/music/browse/recently-added'
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PageBrowseRecentlyPlayed,
|
2023-07-12 11:47:16 -04:00
|
|
|
meta: { has_tabs: true, show_progress: true },
|
|
|
|
name: 'music-browse-recently-played',
|
|
|
|
path: '/music/browse/recently-played'
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
2023-07-12 15:30:52 -04:00
|
|
|
{
|
|
|
|
component: PageBrowseSpotify,
|
|
|
|
meta: { has_tabs: true, show_progress: true },
|
|
|
|
name: 'music-spotify',
|
|
|
|
path: '/music/spotify'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PageBrowseSpotifyFeaturedPlaylists,
|
|
|
|
meta: { has_tabs: true, show_progress: true },
|
|
|
|
name: 'music-spotify-featured-playlists',
|
|
|
|
path: '/music/spotify/featured-playlists'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PageBrowseSpotifyNewReleases,
|
|
|
|
meta: { has_tabs: true, show_progress: true },
|
|
|
|
name: 'music-spotify-new-releases',
|
|
|
|
path: '/music/spotify/new-releases'
|
|
|
|
},
|
2023-07-12 17:02:02 -04:00
|
|
|
{
|
|
|
|
component: PageComposerAlbums,
|
|
|
|
meta: { show_progress: true, has_index: true },
|
|
|
|
name: 'music-composer-albums',
|
|
|
|
path: '/music/composers/:name/albums'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PageComposerTracks,
|
|
|
|
meta: { has_index: true, show_progress: true },
|
|
|
|
name: 'music-composer-tracks',
|
|
|
|
path: '/music/composers/:name/tracks'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PageComposers,
|
|
|
|
meta: { has_index: true, has_tabs: true, show_progress: true },
|
|
|
|
name: 'music-composers',
|
|
|
|
path: '/music/composers'
|
|
|
|
},
|
2023-07-10 07:24:42 -04:00
|
|
|
{
|
|
|
|
component: PageFiles,
|
|
|
|
meta: { show_progress: true },
|
|
|
|
name: 'files',
|
|
|
|
path: '/files'
|
|
|
|
},
|
2018-10-26 11:17:18 -04:00
|
|
|
{
|
|
|
|
component: PageGenre,
|
2023-07-10 14:54:52 -04:00
|
|
|
meta: { has_index: true, show_progress: true },
|
|
|
|
path: '/music/genres/:genre',
|
|
|
|
name: 'music-genre'
|
2018-10-26 11:17:18 -04:00
|
|
|
},
|
2018-11-24 11:22:23 -05:00
|
|
|
{
|
|
|
|
path: '/music/genres/:genre/tracks',
|
2023-07-10 14:54:52 -04:00
|
|
|
name: 'music-genre-tracks',
|
2018-11-24 11:22:23 -05:00
|
|
|
component: PageGenreTracks,
|
2018-12-19 07:02:38 -05:00
|
|
|
meta: { show_progress: true, has_index: true }
|
2018-11-24 11:22:23 -05:00
|
|
|
},
|
2023-07-10 14:54:52 -04:00
|
|
|
{
|
|
|
|
component: PageGenres,
|
|
|
|
meta: { has_index: true, has_tabs: true, show_progress: true },
|
|
|
|
path: '/music/genres',
|
|
|
|
name: 'music-genres'
|
|
|
|
},
|
2023-07-10 06:19:34 -04:00
|
|
|
{
|
|
|
|
component: PageNowPlaying,
|
|
|
|
name: 'now-playing',
|
2023-07-10 09:37:40 -04:00
|
|
|
path: '/now-playing'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'playlists',
|
2023-07-10 14:33:07 -04:00
|
|
|
redirect: '/playlists/0'
|
2023-07-10 09:37:40 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PagePlaylist,
|
|
|
|
meta: { show_progress: true },
|
|
|
|
name: 'playlist',
|
2023-07-10 14:33:07 -04:00
|
|
|
path: '/playlists/:id'
|
2023-07-10 09:37:40 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PagePlaylistSpotify,
|
|
|
|
meta: { show_progress: true },
|
|
|
|
name: 'playlist-spotify',
|
2023-07-10 14:33:07 -04:00
|
|
|
path: '/playlists/spotify/:id'
|
2023-07-10 09:37:40 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PagePlaylistTracks,
|
|
|
|
meta: { show_progress: true },
|
|
|
|
name: 'playlist-tracks',
|
2023-07-10 14:33:07 -04:00
|
|
|
path: '/playlists/:id/tracks'
|
2023-07-10 06:19:34 -04:00
|
|
|
},
|
2023-07-10 04:03:05 -04:00
|
|
|
{
|
|
|
|
component: PagePodcast,
|
|
|
|
meta: { show_progress: true },
|
|
|
|
name: 'podcast',
|
2023-07-10 14:33:07 -04:00
|
|
|
path: '/podcasts/:id'
|
2023-07-10 04:03:05 -04:00
|
|
|
},
|
2018-08-11 01:47:10 -04:00
|
|
|
{
|
|
|
|
component: PagePodcasts,
|
2023-07-10 07:09:27 -04:00
|
|
|
meta: { show_progress: true },
|
|
|
|
name: 'podcasts',
|
2023-07-10 09:37:40 -04:00
|
|
|
path: '/podcasts'
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
2023-07-10 13:25:17 -04:00
|
|
|
{
|
|
|
|
component: PageRadioStreams,
|
|
|
|
meta: { show_progress: true },
|
|
|
|
name: 'radio',
|
|
|
|
path: '/radio'
|
|
|
|
},
|
2023-07-10 05:57:29 -04:00
|
|
|
{
|
|
|
|
component: PageQueue,
|
|
|
|
name: 'queue',
|
|
|
|
path: '/'
|
|
|
|
},
|
2018-08-11 01:47:10 -04:00
|
|
|
{
|
2023-07-10 06:10:39 -04:00
|
|
|
component: PageSearchLibrary,
|
|
|
|
name: 'search-library',
|
|
|
|
path: '/search/library'
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
2023-07-10 07:58:26 -04:00
|
|
|
{
|
|
|
|
component: PageSearchSpotify,
|
|
|
|
name: 'search-spotify',
|
2023-07-10 09:37:40 -04:00
|
|
|
path: '/search/spotify'
|
2023-07-10 07:58:26 -04:00
|
|
|
},
|
2023-07-11 03:51:17 -04:00
|
|
|
{
|
|
|
|
component: PageSettingsWebinterface,
|
|
|
|
name: 'settings-webinterface',
|
|
|
|
path: '/settings/webinterface'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PageSettingsArtwork,
|
|
|
|
name: 'settings-artwork',
|
|
|
|
path: '/settings/artwork'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PageSettingsOnlineServices,
|
|
|
|
name: 'settings-online-services',
|
|
|
|
path: '/settings/online-services'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PageSettingsRemotesOutputs,
|
|
|
|
name: 'settings-remotes-outputs',
|
|
|
|
path: '/settings/remotes-outputs'
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
|
|
|
],
|
2022-02-19 00:39:14 -05:00
|
|
|
scrollBehavior(to, from, savedPosition) {
|
2022-02-19 00:18:01 -05:00
|
|
|
const wait_ms = 0
|
2018-08-11 01:47:10 -04:00
|
|
|
if (savedPosition) {
|
2022-02-19 00:18:01 -05:00
|
|
|
// We have saved scroll position (browser back/forward navigation), use this position
|
2018-08-11 01:47:10 -04:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
setTimeout(() => {
|
|
|
|
resolve(savedPosition)
|
2022-02-19 00:18:01 -05:00
|
|
|
}, wait_ms)
|
2018-08-11 01:47:10 -04:00
|
|
|
})
|
2022-02-19 00:18:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (to.path === from.path && to.hash) {
|
2023-07-12 11:25:47 -04:00
|
|
|
// We are staying on the same page and are jumping to an anchor (e. g. index nav)
|
2022-02-19 00:18:01 -05:00
|
|
|
// We don't have a transition, so don't add a timeout!
|
|
|
|
return { el: to.hash, top: 120 }
|
|
|
|
}
|
|
|
|
|
|
|
|
if (to.hash) {
|
2023-07-12 11:25:47 -04:00
|
|
|
// We are navigating to an anchor of a new page, add a timeout to let the transition effect finish before scrolling
|
2018-12-08 02:48:15 -05:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
setTimeout(() => {
|
2022-02-19 00:18:01 -05:00
|
|
|
resolve({ el: to.hash, top: 120 })
|
|
|
|
}, wait_ms)
|
2018-12-08 02:48:15 -05:00
|
|
|
})
|
2022-02-19 00:18:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (to.meta.has_index) {
|
|
|
|
// We are navigating to a page with index nav, that should be hidden automatically
|
2023-07-12 11:25:47 -04:00
|
|
|
// Depending on wether we have a tab navigation, add an offset to the "top" anchor
|
2018-12-08 02:48:15 -05:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
setTimeout(() => {
|
2018-12-20 00:32:53 -05:00
|
|
|
if (to.meta.has_tabs) {
|
2022-02-19 00:18:01 -05:00
|
|
|
resolve({ el: '#top', top: 140 })
|
2018-12-20 00:32:53 -05:00
|
|
|
} else {
|
2022-02-19 01:47:54 -05:00
|
|
|
resolve({ el: '#top', top: 110 })
|
2018-12-20 00:32:53 -05:00
|
|
|
}
|
2022-02-19 00:18:01 -05:00
|
|
|
}, wait_ms)
|
2018-12-08 02:48:15 -05:00
|
|
|
})
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
2022-02-19 00:18:01 -05:00
|
|
|
|
|
|
|
return { left: 0, top: 0 }
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
2020-04-18 00:57:55 -04:00
|
|
|
if (store.state.show_burger_menu) {
|
2019-07-06 09:21:29 -04:00
|
|
|
store.commit(types.SHOW_BURGER_MENU, false)
|
2020-04-18 00:57:55 -04:00
|
|
|
next(false)
|
|
|
|
return
|
2019-07-06 09:21:29 -04:00
|
|
|
}
|
2020-04-18 00:57:55 -04:00
|
|
|
if (store.state.show_player_menu) {
|
|
|
|
store.commit(types.SHOW_PLAYER_MENU, false)
|
|
|
|
next(false)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
next(true)
|
2018-08-11 01:47:10 -04:00
|
|
|
})
|