mirror of
https://github.com/Spythere/station-manager-2.0.git
synced 2026-05-04 05:58:13 +00:00
Migracja projektu na Vite
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
|
||||
|
||||
const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path: '/',
|
||||
name: 'ManagerView',
|
||||
component: () => import('./views/ManagerView.vue'),
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
name: 'LoginView',
|
||||
component: () => import('./views/LoginView.vue'),
|
||||
},
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes,
|
||||
});
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
const token = window.localStorage.getItem('auth-token');
|
||||
|
||||
if (!token && to.path != '/login') return next({ path: '/login' });
|
||||
|
||||
if (token && to.path == '/login') return next({ path: '/' });
|
||||
// else if (to.path == '/login') return next({ path: '/' });
|
||||
|
||||
return next();
|
||||
});
|
||||
|
||||
export default router;
|
||||
Reference in New Issue
Block a user