Select Git revision
Forked from
funkwhale / funkwhale
3793 commits behind the upstream repository.
index.js 29.66 KiB
import Vue from 'vue'
import Router from 'vue-router'
import store from '@/store'
Vue.use(Router)
function adminPermissions (to, from, next) {
if (store.state.auth.authenticated === true && store.state.auth.availablePermissions.settings === true) {
next()
} else {
console.log('Not authenticated. Redirecting to library.')
next({ name: 'library.index' })
}
}
function moderatorPermissions (to, from, next) {
if (store.state.auth.authenticated === true && store.state.auth.availablePermissions.moderation === true) {
next()
} else {
console.log('Not authenticated. Redirecting to library.')
next({ name: 'library.index' })
}
}
function libraryPermissions (to, from, next) {
if (store.state.auth.authenticated === true && store.state.auth.availablePermissions.library === true) {
next()
} else {
console.log('Not authenticated. Redirecting to library.')
next({ name: 'library.index' })
}
}
console.log('PROCESS', process.env)
export default new Router({
mode: 'history',
linkActiveClass: 'active',
base: process.env.VUE_APP_ROUTER_BASE_URL || '/',
scrollBehavior (to, from, savedPosition) {
if (to.meta.preserveScrollPosition) {
return savedPosition
}
return new Promise(resolve => {
setTimeout(() => {
if (to.hash) {
resolve({ selector: to.hash })
}
const pos = savedPosition || { x: 0, y: 0 }
resolve(pos)
}, 100)
})
},
routes: [
{
path: '/',
name: 'index',
component: () =>
import(/* webpackChunkName: "core" */ '@/components/Home')
},
{
path: '/front',
name: 'front',
redirect: to => {
const { hash, query } = to
return { name: 'index', hash, query }
}
},
{
path: '/about',
name: 'about',