Skip to content
Permalink
a4379df259
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
52 lines (45 sloc) 927 Bytes
import Vue from 'vue'
import Router from 'vue-router'
import store from './store';
/**
* Don't forget to import your views here:
*/
import Home from './views/Home.vue'
import About from './views/About.vue'
import Login from './views/Login.vue'
import Profile from './views/Profile.vue'
Vue.use(Router)
const router = new Router({
mode: 'history',
base: process.env.BASE_URL,
routes: [
{
path: '/login',
name: 'login',
component: Login
},
{
path: '/',
name: 'home',
component: Home
},
{
path: '/about',
name: 'about',
component: About
},
{
path: '/profile',
name: 'profile',
component: Profile
}
]
});
/**
* Authentication Check
*/
router.beforeEach((to, from, next) => {
if (to.name !== 'login' && !store.getters.isAuthenticated) next({ name: 'login' })
else next()
})
export default router;