38 lines
751 B
TypeScript
38 lines
751 B
TypeScript
import * as Page from '@/views'
|
|
import { getToken } from '@/helpers'
|
|
|
|
const ifAuthenticated = (to: any, from: any, next: any) => {
|
|
if (getToken()) {
|
|
next()
|
|
return
|
|
}
|
|
next('/login')
|
|
}
|
|
|
|
const ifNotAuthenticated = (to: any, from: any, next: any) => {
|
|
if (!getToken()) {
|
|
next()
|
|
return
|
|
}
|
|
next('/')
|
|
}
|
|
|
|
export const routes: any = [
|
|
{
|
|
path: '/',
|
|
redirect: '/home',
|
|
children: [
|
|
{
|
|
path: 'home',
|
|
name: 'home',
|
|
component: Page.Home,
|
|
},
|
|
{
|
|
path: ':pathMatch(.*)*',
|
|
component: Page.NotFound,
|
|
name: 'page-not-found',
|
|
},
|
|
],
|
|
},
|
|
]
|