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 ArtistTab from '@components/ArtistTab.vue'
|
2020-07-28 20:09:13 +00:00
|
|
|
import TracklistTab from '@components/TracklistTab.vue'
|
|
|
|
|
|
|
|
import TheHomeTab from '@components/TheHomeTab.vue'
|
|
|
|
import TheChartsTab from '@components/TheChartsTab.vue'
|
|
|
|
import TheFavoritesTab from '@components/TheFavoritesTab.vue'
|
|
|
|
import TheErrorsTab from '@components/TheErrorsTab.vue'
|
|
|
|
import TheLinkAnalyzerTab from '@components/TheLinkAnalyzerTab.vue'
|
|
|
|
import TheAboutTab from '@components/TheAboutTab.vue'
|
|
|
|
import TheSettingsTab from '@components/TheSettingsTab.vue'
|
|
|
|
import TheMainSearch from '@components/TheMainSearch.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-21 17:12:14 +00:00
|
|
|
component: TheHomeTab,
|
|
|
|
meta: {
|
|
|
|
notKeepAlive: true
|
|
|
|
}
|
2020-07-28 19:39:44 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
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
|
|
|
|
},
|
2020-07-28 20:09:13 +00:00
|
|
|
{
|
|
|
|
path: '/charts',
|
|
|
|
name: 'Charts',
|
2020-09-21 17:22:09 +00:00
|
|
|
component: TheChartsTab,
|
|
|
|
meta: {
|
|
|
|
notKeepAlive: true
|
|
|
|
}
|
2020-07-28 20:09:13 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/favorites',
|
|
|
|
name: 'Favorites',
|
2020-09-21 19:54:00 +00:00
|
|
|
component: TheFavoritesTab,
|
|
|
|
meta: {
|
|
|
|
notKeepAlive: true
|
|
|
|
}
|
2020-07-28 20:09:13 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/errors',
|
|
|
|
name: 'Errors',
|
|
|
|
component: TheErrorsTab
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/link-analyzer',
|
|
|
|
name: 'Link Analyzer',
|
|
|
|
component: TheLinkAnalyzerTab
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/about',
|
|
|
|
name: 'About',
|
|
|
|
component: TheAboutTab
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/settings',
|
|
|
|
name: 'Settings',
|
|
|
|
component: TheSettingsTab
|
|
|
|
},
|
2020-09-15 20:44:29 +00:00
|
|
|
{
|
|
|
|
path: '/search',
|
|
|
|
name: 'Search',
|
|
|
|
component: TheMainSearch
|
|
|
|
},
|
2020-07-28 19:39:44 +00:00
|
|
|
// 404 client side
|
2020-07-27 20:01:57 +00:00
|
|
|
{
|
|
|
|
path: '*',
|
2020-08-22 21:34:16 +00:00
|
|
|
component: TheHomeTab
|
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-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-28 19:39:44 +00:00
|
|
|
EventBus.$emit('trackPreview:stopStackedTabsPreview')
|
|
|
|
|
2020-07-27 20:01:57 +00:00
|
|
|
next()
|
|
|
|
})
|
|
|
|
|
|
|
|
export default router
|