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-07-28 19:39:44 +00:00
|
|
|
import TheHomeTab from '@components/TheHomeTab.vue'
|
2020-07-27 20:01:57 +00:00
|
|
|
import TracklistTab from '@components/TracklistTab.vue'
|
2020-07-28 19:39:44 +00:00
|
|
|
import ArtistTab from '@components/ArtistTab.vue'
|
2020-07-27 20:01:57 +00:00
|
|
|
|
|
|
|
Vue.use(VueRouter)
|
|
|
|
|
|
|
|
const routes = [
|
|
|
|
{
|
2020-07-28 19:39:44 +00:00
|
|
|
path: '/',
|
|
|
|
component: TheHomeTab
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/tracklist/:type/:id',
|
|
|
|
name: 'Tracklist',
|
2020-07-27 20:01:57 +00:00
|
|
|
component: TracklistTab
|
|
|
|
},
|
2020-07-28 19:39:44 +00:00
|
|
|
{
|
|
|
|
path: '/artist/:id',
|
|
|
|
name: 'Artist',
|
|
|
|
component: ArtistTab
|
|
|
|
},
|
|
|
|
// 404 client side
|
2020-07-27 20:01:57 +00:00
|
|
|
{
|
|
|
|
path: '*',
|
|
|
|
component: TracklistTab
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
const router = new VueRouter({
|
|
|
|
mode: 'history',
|
|
|
|
// linkActiveClass: 'open',
|
|
|
|
routes,
|
|
|
|
scrollBehavior(to, from, savedPosition) {
|
|
|
|
return { x: 0, y: 0 }
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
2020-07-28 19:39:44 +00:00
|
|
|
console.log('before route change', to)
|
|
|
|
|
|
|
|
switch (to.name) {
|
|
|
|
case 'Artist':
|
|
|
|
socket.emit('getTracklist', {
|
|
|
|
type: 'artist',
|
|
|
|
id: to.params.id
|
|
|
|
})
|
|
|
|
break
|
|
|
|
case 'Tracklist':
|
|
|
|
socket.emit('getTracklist', {
|
|
|
|
type: to.params.type,
|
|
|
|
id: to.params.id
|
|
|
|
})
|
|
|
|
break
|
|
|
|
|
|
|
|
default:
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
EventBus.$emit('trackPreview:stopStackedTabsPreview')
|
|
|
|
|
2020-07-27 20:01:57 +00:00
|
|
|
next()
|
|
|
|
})
|
|
|
|
|
|
|
|
export default router
|