局长信箱-互联网端管理-前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

63 lines
1.5 KiB

import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '@/views/Home.vue'
import Layout from '@/layout/Index.vue'
import NotFound from '@/views/error/404.vue'
const constantRoutes = [
{
path: '/layout',
component: Layout,
redirect: to => {
return '/'
},
children: [
{
path: '/',
component: Home
},
{
path: '/mailbox',
component: () => import('@/components/ManageMail.vue'),
},
{
path: '/mailbox/detail/:id',
component: () => import('@/components/MailDetail.vue')
},
{
path: '/user',
component: () => import('@/components/ManageUser.vue')
},
{
path: '/holiday',
component: () => import('@/components/HolidayList.vue')
}
]
},
{
path: '/login',
component: () => import('@/components/LoginView.vue')
},
{
path: '/:catchAll(.*)',
component: NotFound,
meta: {
title: '404'
}
}
];
const router = createRouter({
history: createWebHashHistory(),
routes: constantRoutes
});
router.beforeEach((to, from, next) => {
const user = sessionStorage.getItem("user");
if (!user && to.path !== '/login') {
next('/login');
} else {
next();
}
});
export default router;