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 03:52:52 -04:00
|
|
|
import PageAudiobooksAlbum from '@/pages/PageAudiobooksAlbum.vue'
|
|
|
|
import PageAudiobooksAlbums from '@/pages/PageAudiobooksAlbums.vue'
|
2023-07-10 07:24:42 -04:00
|
|
|
import PageFiles from '@/pages/PageFiles.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'
|
2022-02-19 00:18:01 -05:00
|
|
|
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 PageAudiobooksArtists from '@/pages/PageAudiobooksArtists.vue'
|
|
|
|
import PageAudiobooksArtist from '@/pages/PageAudiobooksArtist.vue'
|
|
|
|
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'
|
2022-02-19 00:18:01 -05:00
|
|
|
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 SettingsPageWebinterface from '@/pages/SettingsPageWebinterface.vue'
|
|
|
|
import SettingsPageArtwork from '@/pages/SettingsPageArtwork.vue'
|
|
|
|
import SettingsPageOnlineServices from '@/pages/SettingsPageOnlineServices.vue'
|
|
|
|
import SettingsPageRemotesOutputs from '@/pages/SettingsPageRemotesOutputs.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 03:52:52 -04:00
|
|
|
{
|
|
|
|
component: PageAudiobooksAlbum,
|
|
|
|
meta: { show_progress: true },
|
2023-07-10 14:08:35 -04:00
|
|
|
name: 'audiobooks-album',
|
|
|
|
path: '/audiobooks/album/:id'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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',
|
|
|
|
path: '/audiobooks/artist/:id'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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
|
|
|
{
|
|
|
|
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 }
|
|
|
|
},
|
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
|
|
|
{
|
|
|
|
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,
|
2023-06-23 16:26:09 -04:00
|
|
|
meta: { show_progress: true, has_index: true }
|
2021-10-23 05:48:11 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/music/composers/:composer/tracks',
|
|
|
|
name: 'ComposerTracks',
|
|
|
|
component: PageComposerTracks,
|
2023-06-23 16:26:09 -04:00
|
|
|
meta: { show_progress: true, has_index: true }
|
2021-10-23 05:48:11 -04:00
|
|
|
},
|
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',
|
|
|
|
redirect: '/playlist/0'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PagePlaylist,
|
|
|
|
meta: { show_progress: true },
|
|
|
|
name: 'playlist',
|
|
|
|
path: '/playlist/:id'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PagePlaylistSpotify,
|
|
|
|
meta: { show_progress: true },
|
|
|
|
name: 'playlist-spotify',
|
|
|
|
path: '/playlist/spotify/:id'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: PagePlaylistTracks,
|
|
|
|
meta: { show_progress: true },
|
|
|
|
name: 'playlist-tracks',
|
|
|
|
path: '/playlist/: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',
|
|
|
|
path: '/podcast/:id'
|
|
|
|
},
|
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
|
|
|
name: 'search',
|
2018-08-11 01:47:10 -04:00
|
|
|
path: '/search',
|
|
|
|
redirect: '/search/library'
|
|
|
|
},
|
|
|
|
{
|
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
|
|
|
},
|
2018-08-11 01:47:10 -04:00
|
|
|
{
|
|
|
|
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 }
|
|
|
|
},
|
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
|
|
|
}
|
|
|
|
],
|
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) {
|
|
|
|
// 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 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
|
|
|
})
|