added artist and tracklist tab routing

This commit is contained in:
Roberto Tonino
2020-07-28 21:39:44 +02:00
parent 9346f89d48
commit 20460ef9ce
11 changed files with 204 additions and 156 deletions

View File

@@ -1,18 +1,30 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import { socket } from '@/utils/socket'
import EventBus from '@/utils/EventBus'
import TheHomeTab from '@components/TheHomeTab.vue'
import TracklistTab from '@components/TracklistTab.vue'
console.log(TracklistTab)
import ArtistTab from '@components/ArtistTab.vue'
Vue.use(VueRouter)
const routes = [
{
path: '/tracklist/:id',
path: '/',
component: TheHomeTab
},
{
path: '/tracklist/:type/:id',
name: 'Tracklist',
component: TracklistTab
},
// 404
{
path: '/artist/:id',
name: 'Artist',
component: ArtistTab
},
// 404 client side
{
path: '*',
component: TracklistTab
@@ -29,7 +41,28 @@ const router = new VueRouter({
})
router.beforeEach((to, from, next) => {
console.log({ from, to })
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')
next()
})