2020-07-27 20:01:57 +00:00
|
|
|
import Vue from 'vue'
|
|
|
|
import VueRouter from 'vue-router'
|
2020-07-28 19:39:44 +00:00
|
|
|
import { socket } from '@/utils/socket'
|
|
|
|
import EventBus from '@/utils/EventBus'
|
2020-07-27 20:01:57 +00:00
|
|
|
|
2020-09-26 19:10:40 +00:00
|
|
|
// Pages
|
|
|
|
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'
|
|
|
|
import Search from '@components/pages/Search.vue'
|
|
|
|
import Settings from '@components/pages/Settings.vue'
|
|
|
|
import Tracklist from '@components/pages/Tracklist.vue'
|
2020-07-27 20:01:57 +00:00
|
|
|
|
|
|
|
Vue.use(VueRouter)
|
|
|
|
|
|
|
|
const routes = [
|
|
|
|
{
|
2020-07-28 19:39:44 +00:00
|
|
|
path: '/',
|
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
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/tracklist/:type/:id',
|
|
|
|
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
|
|
|
{
|
|
|
|
path: '/artist/:id',
|
|
|
|
name: 'Artist',
|
2020-09-26 19:10:40 +00:00
|
|
|
component: Artist
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/album/:id',
|
|
|
|
name: 'Album',
|
|
|
|
component: Tracklist
|
|
|
|
},
|
|
|
|
{
|
2020-10-13 20:14:37 +00:00
|
|
|
path: '/playlist/:id',
|
2020-09-26 19:10:40 +00:00
|
|
|
name: 'Playlist',
|
|
|
|
component: Tracklist
|
|
|
|
},
|
|
|
|
{
|
2020-10-13 20:14:37 +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
|
|
|
{
|
|
|
|
path: '/charts',
|
|
|
|
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
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/favorites',
|
|
|
|
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
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/errors',
|
|
|
|
name: 'Errors',
|
2020-09-26 19:10:40 +00:00
|
|
|
component: Errors
|
2020-07-28 20:09:13 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/link-analyzer',
|
|
|
|
name: 'Link Analyzer',
|
2020-09-26 19:10:40 +00:00
|
|
|
component: LinkAnalyzer
|
2020-07-28 20:09:13 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/about',
|
|
|
|
name: 'About',
|
2020-09-26 19:10:40 +00:00
|
|
|
component: About
|
2020-07-28 20:09:13 +00:00
|
|
|
},
|
2020-11-07 13:05:10 +00:00
|
|
|
{
|
|
|
|
path: '/arl',
|
|
|
|
name: 'ARL',
|
|
|
|
component: InfoArl
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/info-spotify',
|
|
|
|
name: 'Spotify Features',
|
|
|
|
component: InfoSpotifyFeatures
|
|
|
|
},
|
2020-07-28 20:09:13 +00:00
|
|
|
{
|
|
|
|
path: '/settings',
|
|
|
|
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
|
|
|
{
|
|
|
|
path: '/search',
|
|
|
|
name: 'Search',
|
2020-09-26 19:10:40 +00:00
|
|
|
component: Search
|
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',
|
|
|
|
// linkActiveClass: 'open',
|
|
|
|
routes,
|
|
|
|
scrollBehavior(to, from, savedPosition) {
|
|
|
|
return { x: 0, y: 0 }
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
2020-08-22 21:34:16 +00:00
|
|
|
let getTracklistParams = null
|
2020-07-28 19:39:44 +00:00
|
|
|
|
|
|
|
switch (to.name) {
|
|
|
|
case 'Artist':
|
2020-08-22 21:34:16 +00:00
|
|
|
getTracklistParams = {
|
2020-07-28 19:39:44 +00:00
|
|
|
type: 'artist',
|
|
|
|
id: to.params.id
|
2020-08-22 21:34:16 +00:00
|
|
|
}
|
2020-07-28 19:39:44 +00:00
|
|
|
break
|
|
|
|
case 'Tracklist':
|
2020-08-22 21:34:16 +00:00
|
|
|
getTracklistParams = {
|
2020-07-28 19:39:44 +00:00
|
|
|
type: to.params.type,
|
|
|
|
id: to.params.id
|
2020-08-22 21:34:16 +00:00
|
|
|
}
|
|
|
|
break
|
2020-09-26 19:10:40 +00:00
|
|
|
case 'Album':
|
|
|
|
getTracklistParams = {
|
|
|
|
type: 'album',
|
|
|
|
id: to.params.id
|
|
|
|
}
|
|
|
|
break
|
|
|
|
case 'Playlist':
|
|
|
|
getTracklistParams = {
|
|
|
|
type: 'playlist',
|
|
|
|
id: to.params.id
|
|
|
|
}
|
|
|
|
break
|
|
|
|
case 'Spotify Playlist':
|
|
|
|
getTracklistParams = {
|
|
|
|
type: 'spotifyplaylist',
|
|
|
|
id: to.params.id
|
|
|
|
}
|
|
|
|
break
|
2020-07-28 19:39:44 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
2020-08-22 21:34:16 +00:00
|
|
|
if (getTracklistParams) {
|
|
|
|
socket.emit('getTracklist', getTracklistParams)
|
|
|
|
}
|
|
|
|
|
2020-07-27 20:01:57 +00:00
|
|
|
next()
|
|
|
|
})
|
|
|
|
|
|
|
|
export default router
|