2020-07-27 20:01:57 +00:00
|
|
|
import Vue from 'vue'
|
|
|
|
import VueRouter from 'vue-router'
|
|
|
|
|
2020-09-26 19:10:40 +00:00
|
|
|
// Pages
|
2021-03-12 19:33:51 +00:00
|
|
|
import About from '@components/pages/About.vue'
|
2020-11-07 13:05:10 +00:00
|
|
|
import InfoArl from '@components/pages/InfoArl.vue'
|
|
|
|
import InfoSpotifyFeatures from '@components/pages/InfoSpotifyFeatures.vue'
|
2020-09-26 19:10:40 +00:00
|
|
|
import Artist from '@components/pages/Artist.vue'
|
|
|
|
import Charts from '@components/pages/Charts.vue'
|
|
|
|
import Errors from '@components/pages/Errors.vue'
|
|
|
|
import Favorites from '@components/pages/Favorites.vue'
|
|
|
|
import Home from '@components/pages/Home.vue'
|
|
|
|
import LinkAnalyzer from '@components/pages/LinkAnalyzer.vue'
|
2021-06-04 20:44:46 +00:00
|
|
|
import Logs from '@components/pages/Logs.vue'
|
2020-09-26 19:10:40 +00:00
|
|
|
import Search from '@components/pages/Search.vue'
|
|
|
|
import Settings from '@components/pages/Settings.vue'
|
|
|
|
import Tracklist from '@components/pages/Tracklist.vue'
|
2021-06-04 20:44:46 +00:00
|
|
|
|
2021-03-01 22:09:14 +00:00
|
|
|
import { fetchData } from '@/utils/api'
|
2021-03-12 19:26:45 +00:00
|
|
|
import EventBus from '@/utils/EventBus'
|
2020-07-27 20:01:57 +00:00
|
|
|
|
|
|
|
Vue.use(VueRouter)
|
|
|
|
|
|
|
|
const routes = [
|
|
|
|
{
|
2021-01-31 15:55:37 +00:00
|
|
|
path: window.location.pathname,
|
2020-08-22 21:34:16 +00:00
|
|
|
name: 'Home',
|
2020-09-26 19:10:40 +00:00
|
|
|
component: Home,
|
2020-09-21 17:12:14 +00:00
|
|
|
meta: {
|
|
|
|
notKeepAlive: true
|
|
|
|
}
|
2020-07-28 19:39:44 +00:00
|
|
|
},
|
|
|
|
{
|
2021-01-31 16:45:06 +00:00
|
|
|
path: '/tracklist/:type/:id',
|
2020-07-28 19:39:44 +00:00
|
|
|
name: 'Tracklist',
|
2020-09-26 19:10:40 +00:00
|
|
|
component: Tracklist
|
2020-07-27 20:01:57 +00:00
|
|
|
},
|
2020-07-28 19:39:44 +00:00
|
|
|
{
|
2021-01-31 16:45:06 +00:00
|
|
|
path: '/artist/:id',
|
2020-07-28 19:39:44 +00:00
|
|
|
name: 'Artist',
|
2020-11-14 21:27:47 +00:00
|
|
|
component: Artist,
|
|
|
|
meta: {
|
|
|
|
notKeepAlive: true
|
|
|
|
}
|
2020-09-26 19:10:40 +00:00
|
|
|
},
|
|
|
|
{
|
2021-01-31 16:45:06 +00:00
|
|
|
path: '/album/:id',
|
2020-09-26 19:10:40 +00:00
|
|
|
name: 'Album',
|
|
|
|
component: Tracklist
|
|
|
|
},
|
|
|
|
{
|
2021-01-31 16:45:06 +00:00
|
|
|
path: '/playlist/:id',
|
2020-09-26 19:10:40 +00:00
|
|
|
name: 'Playlist',
|
|
|
|
component: Tracklist
|
|
|
|
},
|
|
|
|
{
|
2021-01-31 16:45:06 +00:00
|
|
|
path: '/spotify-playlist/:id',
|
2020-09-26 19:10:40 +00:00
|
|
|
name: 'Spotify Playlist',
|
|
|
|
component: Tracklist
|
2020-07-28 19:39:44 +00:00
|
|
|
},
|
2020-07-28 20:09:13 +00:00
|
|
|
{
|
2021-01-31 16:45:06 +00:00
|
|
|
path: '/charts',
|
2020-07-28 20:09:13 +00:00
|
|
|
name: 'Charts',
|
2020-09-26 19:10:40 +00:00
|
|
|
component: Charts,
|
2020-09-21 17:22:09 +00:00
|
|
|
meta: {
|
|
|
|
notKeepAlive: true
|
|
|
|
}
|
2020-07-28 20:09:13 +00:00
|
|
|
},
|
|
|
|
{
|
2021-01-31 16:45:06 +00:00
|
|
|
path: '/favorites',
|
2020-07-28 20:09:13 +00:00
|
|
|
name: 'Favorites',
|
2020-09-26 19:10:40 +00:00
|
|
|
component: Favorites,
|
2020-09-21 19:54:00 +00:00
|
|
|
meta: {
|
|
|
|
notKeepAlive: true
|
|
|
|
}
|
2020-07-28 20:09:13 +00:00
|
|
|
},
|
|
|
|
{
|
2021-01-31 16:45:06 +00:00
|
|
|
path: '/errors',
|
2020-07-28 20:09:13 +00:00
|
|
|
name: 'Errors',
|
2020-09-26 19:10:40 +00:00
|
|
|
component: Errors
|
2020-07-28 20:09:13 +00:00
|
|
|
},
|
2021-06-04 20:44:46 +00:00
|
|
|
{
|
|
|
|
path: '/logs',
|
|
|
|
name: 'Logs',
|
|
|
|
component: Logs
|
|
|
|
},
|
2020-07-28 20:09:13 +00:00
|
|
|
{
|
2021-01-31 16:45:06 +00:00
|
|
|
path: '/link-analyzer',
|
2020-07-28 20:09:13 +00:00
|
|
|
name: 'Link Analyzer',
|
2020-09-26 19:10:40 +00:00
|
|
|
component: LinkAnalyzer
|
2020-07-28 20:09:13 +00:00
|
|
|
},
|
2021-03-12 19:33:51 +00:00
|
|
|
{
|
2021-01-31 16:45:06 +00:00
|
|
|
path: '/about',
|
2020-07-28 20:09:13 +00:00
|
|
|
name: 'About',
|
2020-09-26 19:10:40 +00:00
|
|
|
component: About
|
2021-03-12 19:33:51 +00:00
|
|
|
},
|
2020-11-07 13:05:10 +00:00
|
|
|
{
|
2021-01-31 16:45:06 +00:00
|
|
|
path: '/info-arl',
|
2020-11-07 13:05:10 +00:00
|
|
|
name: 'ARL',
|
|
|
|
component: InfoArl
|
|
|
|
},
|
|
|
|
{
|
2021-01-31 16:45:06 +00:00
|
|
|
path: '/info-spotify',
|
2020-11-07 13:05:10 +00:00
|
|
|
name: 'Spotify Features',
|
|
|
|
component: InfoSpotifyFeatures
|
|
|
|
},
|
2020-07-28 20:09:13 +00:00
|
|
|
{
|
2021-01-31 16:45:06 +00:00
|
|
|
path: '/settings',
|
2020-07-28 20:09:13 +00:00
|
|
|
name: 'Settings',
|
2020-09-26 19:10:40 +00:00
|
|
|
component: Settings
|
2020-07-28 20:09:13 +00:00
|
|
|
},
|
2020-09-15 20:44:29 +00:00
|
|
|
{
|
2021-01-31 16:45:06 +00:00
|
|
|
path: '/search',
|
2020-09-15 20:44:29 +00:00
|
|
|
name: 'Search',
|
2020-11-23 20:37:18 +00:00
|
|
|
component: Search,
|
|
|
|
meta: {
|
|
|
|
notKeepAlive: true
|
|
|
|
}
|
2020-09-15 20:44:29 +00:00
|
|
|
},
|
2020-07-28 19:39:44 +00:00
|
|
|
// 404 client side
|
2020-07-27 20:01:57 +00:00
|
|
|
{
|
|
|
|
path: '*',
|
2020-09-26 19:10:40 +00:00
|
|
|
component: Home
|
2020-07-27 20:01:57 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
const router = new VueRouter({
|
|
|
|
mode: 'history',
|
|
|
|
routes,
|
|
|
|
scrollBehavior(to, from, savedPosition) {
|
|
|
|
return { x: 0, y: 0 }
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
2020-07-28 19:39:44 +00:00
|
|
|
switch (to.name) {
|
2021-03-12 19:26:45 +00:00
|
|
|
case 'Tracklist': {
|
|
|
|
// const getTracklistParams = {
|
|
|
|
// type: to.params.type,
|
|
|
|
// id: to.params.id
|
|
|
|
// }
|
|
|
|
console.warn('This should never happen.')
|
2020-08-22 21:34:16 +00:00
|
|
|
break
|
2021-03-12 19:26:45 +00:00
|
|
|
}
|
|
|
|
case 'Album': {
|
|
|
|
const getTracklistParams = {
|
2020-09-26 19:10:40 +00:00
|
|
|
type: 'album',
|
|
|
|
id: to.params.id
|
|
|
|
}
|
2021-03-12 19:26:45 +00:00
|
|
|
fetchData('getTracklist', getTracklistParams).then(albumData => {
|
|
|
|
EventBus.$emit('showAlbum', albumData)
|
|
|
|
})
|
2020-09-26 19:10:40 +00:00
|
|
|
break
|
2021-03-12 19:26:45 +00:00
|
|
|
}
|
|
|
|
case 'Playlist': {
|
|
|
|
const getTracklistParams = {
|
2020-09-26 19:10:40 +00:00
|
|
|
type: 'playlist',
|
|
|
|
id: to.params.id
|
|
|
|
}
|
2021-03-12 19:26:45 +00:00
|
|
|
fetchData('getTracklist', getTracklistParams).then(playlistData => {
|
|
|
|
EventBus.$emit('showPlaylist', playlistData)
|
|
|
|
})
|
2020-09-26 19:10:40 +00:00
|
|
|
break
|
2021-03-12 19:26:45 +00:00
|
|
|
}
|
|
|
|
case 'Spotify Playlist': {
|
|
|
|
const getTracklistParams = {
|
2020-09-26 19:10:40 +00:00
|
|
|
type: 'spotifyplaylist',
|
|
|
|
id: to.params.id
|
|
|
|
}
|
2021-03-12 19:26:45 +00:00
|
|
|
fetchData('getTracklist', getTracklistParams).then(spotifyPlaylistData => {
|
|
|
|
EventBus.$emit('showSpotifyPlaylist', spotifyPlaylistData)
|
|
|
|
})
|
2020-09-26 19:10:40 +00:00
|
|
|
break
|
2021-03-12 19:26:45 +00:00
|
|
|
}
|
2020-07-28 19:39:44 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
2020-07-27 20:01:57 +00:00
|
|
|
next()
|
|
|
|
})
|
|
|
|
|
|
|
|
export default router
|