2022-02-19 00:18:01 -05:00
|
|
|
import { createRouter, createWebHashHistory } from 'vue-router'
|
2018-08-11 01:47:10 -04:00
|
|
|
import store from '@/store'
|
|
|
|
import * as types from '@/store/mutation_types'
|
2022-02-19 00:18:01 -05:00
|
|
|
import PageQueue from '@/pages/PageQueue.vue'
|
|
|
|
import PageNowPlaying from '@/pages/PageNowPlaying.vue'
|
|
|
|
import PageBrowse from '@/pages/PageBrowse.vue'
|
|
|
|
import PageBrowseRecentlyAdded from '@/pages/PageBrowseRecentlyAdded.vue'
|
|
|
|
import PageBrowseRecentlyPlayed from '@/pages/PageBrowseRecentlyPlayed.vue'
|
|
|
|
import PageArtists from '@/pages/PageArtists.vue'
|
|
|
|
import PageArtist from '@/pages/PageArtist.vue'
|
|
|
|
import PageAlbums from '@/pages/PageAlbums.vue'
|
|
|
|
import PageAlbum from '@/pages/PageAlbum.vue'
|
|
|
|
import PageGenres from '@/pages/PageGenres.vue'
|
|
|
|
import PageGenre from '@/pages/PageGenre.vue'
|
|
|
|
import PageGenreTracks from '@/pages/PageGenreTracks.vue'
|
|
|
|
import PageArtistTracks from '@/pages/PageArtistTracks.vue'
|
|
|
|
import PageComposers from '@/pages/PageComposers.vue'
|
|
|
|
import PageComposer from '@/pages/PageComposer.vue'
|
|
|
|
import PageComposerTracks from '@/pages/PageComposerTracks.vue'
|
|
|
|
import PagePodcasts from '@/pages/PagePodcasts.vue'
|
|
|
|
import PagePodcast from '@/pages/PagePodcast.vue'
|
|
|
|
import PageAudiobooksAlbums from '@/pages/PageAudiobooksAlbums.vue'
|
|
|
|
import PageAudiobooksArtists from '@/pages/PageAudiobooksArtists.vue'
|
|
|
|
import PageAudiobooksArtist from '@/pages/PageAudiobooksArtist.vue'
|
|
|
|
import PageAudiobooksAlbum from '@/pages/PageAudiobooksAlbum.vue'
|
|
|
|
import PagePlaylists from '@/pages/PagePlaylists.vue'
|
|
|
|
import PagePlaylist from '@/pages/PagePlaylist.vue'
|
|
|
|
import PageFiles from '@/pages/PageFiles.vue'
|
|
|
|
import PageRadioStreams from '@/pages/PageRadioStreams.vue'
|
|
|
|
import PageSearch from '@/pages/PageSearch.vue'
|
|
|
|
import PageAbout from '@/pages/PageAbout.vue'
|
|
|
|
import SpotifyPageBrowse from '@/pages/SpotifyPageBrowse.vue'
|
|
|
|
import SpotifyPageBrowseNewReleases from '@/pages/SpotifyPageBrowseNewReleases.vue'
|
|
|
|
import SpotifyPageBrowseFeaturedPlaylists from '@/pages/SpotifyPageBrowseFeaturedPlaylists.vue'
|
|
|
|
import SpotifyPageArtist from '@/pages/SpotifyPageArtist.vue'
|
|
|
|
import SpotifyPageAlbum from '@/pages/SpotifyPageAlbum.vue'
|
|
|
|
import SpotifyPagePlaylist from '@/pages/SpotifyPagePlaylist.vue'
|
|
|
|
import SpotifyPageSearch from '@/pages/SpotifyPageSearch.vue'
|
|
|
|
import SettingsPageWebinterface from '@/pages/SettingsPageWebinterface.vue'
|
|
|
|
import SettingsPageArtwork from '@/pages/SettingsPageArtwork.vue'
|
|
|
|
import SettingsPageOnlineServices from '@/pages/SettingsPageOnlineServices.vue'
|
|
|
|
import SettingsPageRemotesOutputs from '@/pages/SettingsPageRemotesOutputs.vue'
|
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: [
|
|
|
|
{
|
|
|
|
path: '/',
|
|
|
|
name: 'PageQueue',
|
|
|
|
component: PageQueue
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/about',
|
|
|
|
name: 'About',
|
|
|
|
component: PageAbout
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/now-playing',
|
|
|
|
name: 'Now playing',
|
|
|
|
component: PageNowPlaying
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/music',
|
|
|
|
redirect: '/music/browse'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/music/browse',
|
|
|
|
name: 'Browse',
|
|
|
|
component: PageBrowse,
|
2018-12-20 00:32:53 -05:00
|
|
|
meta: { show_progress: true, has_tabs: true }
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/music/browse/recently_added',
|
|
|
|
name: 'Browse Recently Added',
|
|
|
|
component: PageBrowseRecentlyAdded,
|
2018-12-20 00:32:53 -05:00
|
|
|
meta: { show_progress: true, has_tabs: true }
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/music/browse/recently_played',
|
|
|
|
name: 'Browse Recently Played',
|
|
|
|
component: PageBrowseRecentlyPlayed,
|
2018-12-20 00:32:53 -05:00
|
|
|
meta: { show_progress: true, has_tabs: true }
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/music/artists',
|
|
|
|
name: 'Artists',
|
|
|
|
component: PageArtists,
|
2018-12-20 00:32:53 -05:00
|
|
|
meta: { show_progress: true, has_tabs: true, has_index: true }
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/music/artists/:artist_id',
|
|
|
|
name: 'Artist',
|
|
|
|
component: PageArtist,
|
2020-10-17 06:07:27 -04:00
|
|
|
meta: { show_progress: true, has_index: true }
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
2018-10-26 11:36:30 -04:00
|
|
|
{
|
2018-10-27 01:12:07 -04:00
|
|
|
path: '/music/artists/:artist_id/tracks',
|
2018-10-26 11:36:30 -04:00
|
|
|
name: 'Tracks',
|
2018-12-19 11:35:49 -05:00
|
|
|
component: PageArtistTracks,
|
2018-12-19 11:50:02 -05:00
|
|
|
meta: { show_progress: true, has_index: true }
|
2018-10-26 11:36:30 -04:00
|
|
|
},
|
2018-08-11 01:47:10 -04:00
|
|
|
{
|
|
|
|
path: '/music/albums',
|
|
|
|
name: 'Albums',
|
|
|
|
component: PageAlbums,
|
2018-12-20 00:32:53 -05:00
|
|
|
meta: { show_progress: true, has_tabs: true, has_index: true }
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/music/albums/:album_id',
|
|
|
|
name: 'Album',
|
|
|
|
component: PageAlbum,
|
|
|
|
meta: { show_progress: true }
|
|
|
|
},
|
2018-10-26 11:17:18 -04:00
|
|
|
{
|
|
|
|
path: '/music/genres',
|
|
|
|
name: 'Genres',
|
|
|
|
component: PageGenres,
|
2018-12-20 00:32:53 -05:00
|
|
|
meta: { show_progress: true, has_tabs: true, has_index: true }
|
2018-10-26 11:17:18 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/music/genres/:genre',
|
|
|
|
name: 'Genre',
|
|
|
|
component: PageGenre,
|
2018-12-19 07:02:38 -05:00
|
|
|
meta: { show_progress: true, has_index: true }
|
2018-10-26 11:17:18 -04:00
|
|
|
},
|
2018-11-24 11:22:23 -05:00
|
|
|
{
|
|
|
|
path: '/music/genres/:genre/tracks',
|
|
|
|
name: 'GenreTracks',
|
|
|
|
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
|
|
|
},
|
2021-10-23 05:48:11 -04:00
|
|
|
{
|
|
|
|
path: '/music/composers',
|
|
|
|
name: 'Composers',
|
|
|
|
component: PageComposers,
|
|
|
|
meta: { show_progress: true, has_tabs: true, has_index: true }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/music/composers/:composer/albums',
|
|
|
|
name: 'ComposerAlbums',
|
|
|
|
component: PageComposer,
|
|
|
|
meta: { show_progress: true, has_tabs: true, has_index: true }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/music/composers/:composer/tracks',
|
|
|
|
name: 'ComposerTracks',
|
|
|
|
component: PageComposerTracks,
|
|
|
|
meta: { show_progress: true, has_tabs: true, has_index: true }
|
|
|
|
},
|
2018-08-11 01:47:10 -04:00
|
|
|
{
|
|
|
|
path: '/podcasts',
|
|
|
|
name: 'Podcasts',
|
|
|
|
component: PagePodcasts,
|
|
|
|
meta: { show_progress: true }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/podcasts/:album_id',
|
|
|
|
name: 'Podcast',
|
|
|
|
component: PagePodcast,
|
|
|
|
meta: { show_progress: true }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/audiobooks',
|
2020-07-01 01:29:03 -04:00
|
|
|
redirect: '/audiobooks/artists'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/audiobooks/artists',
|
|
|
|
name: 'AudiobooksArtists',
|
|
|
|
component: PageAudiobooksArtists,
|
2020-08-30 13:29:12 -04:00
|
|
|
meta: { show_progress: true, has_tabs: true, has_index: true }
|
2020-07-01 01:29:03 -04:00
|
|
|
},
|
2020-09-20 02:13:19 -04:00
|
|
|
{
|
|
|
|
path: '/audiobooks/artists/:artist_id',
|
|
|
|
name: 'AudiobooksArtist',
|
|
|
|
component: PageAudiobooksArtist,
|
|
|
|
meta: { show_progress: true }
|
|
|
|
},
|
2020-07-01 01:29:03 -04:00
|
|
|
{
|
|
|
|
path: '/audiobooks/albums',
|
|
|
|
name: 'AudiobooksAlbums',
|
2020-09-20 02:15:46 -04:00
|
|
|
component: PageAudiobooksAlbums,
|
2020-09-27 13:22:33 -04:00
|
|
|
meta: { show_progress: true, has_tabs: true, has_index: true }
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/audiobooks/:album_id',
|
|
|
|
name: 'Audiobook',
|
2020-09-20 02:15:46 -04:00
|
|
|
component: PageAudiobooksAlbum,
|
2018-08-11 01:47:10 -04:00
|
|
|
meta: { show_progress: true }
|
|
|
|
},
|
2020-08-23 02:52:46 -04:00
|
|
|
{
|
|
|
|
path: '/radio',
|
|
|
|
name: 'Radio',
|
|
|
|
component: PageRadioStreams,
|
|
|
|
meta: { show_progress: true }
|
|
|
|
},
|
2018-12-23 04:34:46 -05:00
|
|
|
{
|
|
|
|
path: '/files',
|
|
|
|
name: 'Files',
|
|
|
|
component: PageFiles,
|
|
|
|
meta: { show_progress: true }
|
|
|
|
},
|
2018-08-11 01:47:10 -04:00
|
|
|
{
|
|
|
|
path: '/playlists',
|
2020-03-08 06:56:19 -04:00
|
|
|
redirect: '/playlists/0'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/playlists/:playlist_id',
|
2018-08-11 01:47:10 -04:00
|
|
|
name: 'Playlists',
|
|
|
|
component: PagePlaylists,
|
|
|
|
meta: { show_progress: true }
|
|
|
|
},
|
|
|
|
{
|
2020-03-08 06:56:19 -04:00
|
|
|
path: '/playlists/:playlist_id/tracks',
|
2018-08-11 01:47:10 -04:00
|
|
|
name: 'Playlist',
|
|
|
|
component: PagePlaylist,
|
|
|
|
meta: { show_progress: true }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/search',
|
|
|
|
redirect: '/search/library'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/search/library',
|
|
|
|
name: 'Search Library',
|
|
|
|
component: PageSearch
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/music/spotify',
|
|
|
|
name: 'Spotify',
|
|
|
|
component: SpotifyPageBrowse,
|
2018-12-20 00:32:53 -05:00
|
|
|
meta: { show_progress: true, has_tabs: true }
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/music/spotify/new-releases',
|
|
|
|
name: 'Spotify Browse New Releases',
|
|
|
|
component: SpotifyPageBrowseNewReleases,
|
2018-12-20 00:32:53 -05:00
|
|
|
meta: { show_progress: true, has_tabs: true }
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/music/spotify/featured-playlists',
|
|
|
|
name: 'Spotify Browse Featured Playlists',
|
|
|
|
component: SpotifyPageBrowseFeaturedPlaylists,
|
2018-12-20 00:32:53 -05:00
|
|
|
meta: { show_progress: true, has_tabs: true }
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/music/spotify/artists/:artist_id',
|
|
|
|
name: 'Spotify Artist',
|
|
|
|
component: SpotifyPageArtist,
|
|
|
|
meta: { show_progress: true }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/music/spotify/albums/:album_id',
|
|
|
|
name: 'Spotify Album',
|
|
|
|
component: SpotifyPageAlbum,
|
|
|
|
meta: { show_progress: true }
|
|
|
|
},
|
|
|
|
{
|
2018-10-26 14:10:52 -04:00
|
|
|
path: '/music/spotify/playlists/:playlist_id',
|
2018-08-11 01:47:10 -04:00
|
|
|
name: 'Spotify Playlist',
|
|
|
|
component: SpotifyPagePlaylist,
|
|
|
|
meta: { show_progress: true }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/search/spotify',
|
|
|
|
name: 'Spotify Search',
|
|
|
|
component: SpotifyPageSearch
|
2019-07-07 02:22:56 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/settings/webinterface',
|
|
|
|
name: 'Settings Webinterface',
|
|
|
|
component: SettingsPageWebinterface
|
2020-01-04 12:53:27 -05:00
|
|
|
},
|
2020-03-14 09:13:37 -04:00
|
|
|
{
|
|
|
|
path: '/settings/artwork',
|
|
|
|
name: 'Settings Artwork',
|
|
|
|
component: SettingsPageArtwork
|
|
|
|
},
|
2020-01-04 12:53:27 -05:00
|
|
|
{
|
|
|
|
path: '/settings/online-services',
|
|
|
|
name: 'Settings Online Services',
|
|
|
|
component: SettingsPageOnlineServices
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/settings/remotes-outputs',
|
|
|
|
name: 'Settings Remotes Outputs',
|
|
|
|
component: SettingsPageRemotesOutputs
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
|
|
|
],
|
|
|
|
scrollBehavior (to, from, savedPosition) {
|
2022-02-19 00:18:01 -05:00
|
|
|
const wait_ms = 0
|
2018-12-08 02:48:15 -05:00
|
|
|
// console.log(to.path + '_' + from.path + '__' + to.hash + ' savedPosition:' + savedPosition)
|
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) {
|
|
|
|
// We are staying on the same page and are jumping to an anker (e. g. index nav)
|
|
|
|
// We don't have a transition, so don't add a timeout!
|
|
|
|
return { el: to.hash, top: 120 }
|
|
|
|
}
|
|
|
|
|
|
|
|
if (to.hash) {
|
|
|
|
// We are navigating to an anker 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
|
|
|
|
// Dependending on wether we have a tab navigation, add an offset to the "top" anker
|
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 00:18:01 -05:00
|
|
|
resolve({ el: '#top', top: 100 })
|
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
|
|
|
})
|