new awesome build
This commit is contained in:
67
APP_UI/src/router/index.js
Normal file
67
APP_UI/src/router/index.js
Normal file
@@ -0,0 +1,67 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
import Clients from '../views/Clients.vue';
|
||||
import Login from '../views/Login.vue';
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
name: 'Analytics',
|
||||
component: () => import('../views/Analytics.vue')
|
||||
},
|
||||
{
|
||||
path: '/clients',
|
||||
name: 'Clients',
|
||||
component: Clients
|
||||
},
|
||||
{
|
||||
path: '/certificates',
|
||||
name: 'Certificates',
|
||||
component: () => import('../views/Certificates.vue')
|
||||
},
|
||||
|
||||
{
|
||||
path: '/config/pki',
|
||||
name: 'PKIConfig',
|
||||
component: () => import('../views/PKIConfig.vue')
|
||||
},
|
||||
{
|
||||
path: '/config/vpn',
|
||||
name: 'VPNConfig',
|
||||
component: () => import('../views/VPNConfig.vue')
|
||||
},
|
||||
{
|
||||
path: '/server',
|
||||
name: 'ServerManagement',
|
||||
component: () => import('../views/ServerManagement.vue')
|
||||
},
|
||||
{
|
||||
path: '/account',
|
||||
name: 'Account',
|
||||
component: () => import('../views/Account.vue')
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
name: 'Login',
|
||||
component: Login,
|
||||
meta: { public: true }
|
||||
}
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes
|
||||
});
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
const isAuthenticated = !!localStorage.getItem('ovpmon_token');
|
||||
|
||||
if (!to.meta.public && !isAuthenticated) {
|
||||
next({ name: 'Login' });
|
||||
} else if (to.name === 'Login' && isAuthenticated) {
|
||||
next({ name: 'Analytics' });
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
Reference in New Issue
Block a user