mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/unity.git
synced 2026-08-19 04:13:58 +00:00
118 lines
2.9 KiB
JavaScript
Vendored
118 lines
2.9 KiB
JavaScript
Vendored
import Vue from 'vue'
|
|
import Router from 'vue-router'
|
|
Vue.use(Router);
|
|
|
|
import Logins from './pages/logins/Index';
|
|
import Dashboards from './pages/dashboards/Index';
|
|
import UserProfile from './pages/users/Profile';
|
|
|
|
import ContractList from './pages/contracts/List';
|
|
import ContractCreate from './pages/contracts/Create';
|
|
import ContractEdit from './pages/contracts/Edit';
|
|
|
|
import PageNotFound from './pages/page-not-founds/Index';
|
|
|
|
let router = new Router({
|
|
mode: 'history',
|
|
base: process.env.MIX_SUB_URL,
|
|
scrollBehavior() {
|
|
return window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
},
|
|
routes: [
|
|
/////////////////////////////////////////////////////
|
|
// Login
|
|
{
|
|
path: '/login',
|
|
name: 'Login',
|
|
meta: {
|
|
layout: 'userpages',
|
|
guest: true
|
|
},
|
|
component: Logins
|
|
},
|
|
///////////////////////////////////////////////////
|
|
// Dashboard
|
|
{
|
|
path: '/',
|
|
name: 'Dashboards',
|
|
meta: {
|
|
auth: true
|
|
},
|
|
component: Dashboards
|
|
},
|
|
/////////////////////////////////////////////////////
|
|
// Contract
|
|
{
|
|
path: '/contract/list',
|
|
name: 'Contract List',
|
|
meta: {
|
|
auth: true
|
|
},
|
|
component: ContractList
|
|
},
|
|
{
|
|
path: '/contract/create',
|
|
name: 'Contract Create',
|
|
meta: {
|
|
auth: true
|
|
},
|
|
component: ContractCreate
|
|
},
|
|
{
|
|
path: '/contract/edit/:hash_id',
|
|
name: 'Contract Edit',
|
|
meta: {
|
|
auth: true
|
|
},
|
|
component: ContractEdit
|
|
},
|
|
/////////////////////////////////////////////////////
|
|
// User
|
|
{
|
|
path: '/user/profile/update',
|
|
name: 'User Profile',
|
|
meta: {
|
|
auth: true
|
|
},
|
|
component: UserProfile
|
|
},
|
|
/////////////////////////////////////////////////////
|
|
// 404
|
|
{
|
|
path: '*',
|
|
name: 'Page 404',
|
|
meta: {
|
|
layout: 'userpages',
|
|
guest: true
|
|
},
|
|
component: PageNotFound
|
|
},
|
|
/////////////////////////////////////////////////////
|
|
]
|
|
});
|
|
|
|
window.TOKEN = localStorage.getItem('user_jwt');
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
if(to.matched.some(record => record.meta.auth)) {
|
|
if (localStorage.getItem('user_jwt') == null) {
|
|
next({ path: 'login' })
|
|
}
|
|
else {
|
|
next();
|
|
}
|
|
}
|
|
|
|
if(to.matched.some(record => record.meta.without_auth)) {
|
|
if (localStorage.getItem('user_jwt') != null) {
|
|
next({ path: '/' })
|
|
}
|
|
else {
|
|
next();
|
|
}
|
|
}
|
|
next();
|
|
});
|
|
|
|
|
|
export default router; |