feat: routes guard
This commit is contained in:
parent
ac1dddf5c3
commit
9558d95fcf
1 changed files with 31 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import { RouteRecordRaw } from 'vue-router';
|
import { RouteRecordRaw } from 'vue-router';
|
||||||
|
import { isRoleInclude } from 'stores/utils';
|
||||||
|
|
||||||
const routes: RouteRecordRaw[] = [
|
const routes: RouteRecordRaw[] = [
|
||||||
{
|
{
|
||||||
|
|
@ -14,11 +15,41 @@ const routes: RouteRecordRaw[] = [
|
||||||
{
|
{
|
||||||
path: '/branch-management',
|
path: '/branch-management',
|
||||||
name: 'BranchManagement',
|
name: 'BranchManagement',
|
||||||
|
beforeEnter: (to, from, next) => {
|
||||||
|
if (
|
||||||
|
isRoleInclude([
|
||||||
|
'admin',
|
||||||
|
'branch_admin',
|
||||||
|
'head_of_admin',
|
||||||
|
'system',
|
||||||
|
'owner',
|
||||||
|
])
|
||||||
|
) {
|
||||||
|
next();
|
||||||
|
} else {
|
||||||
|
next('/');
|
||||||
|
}
|
||||||
|
},
|
||||||
component: () => import('pages/01_branch-management/MainPage.vue'),
|
component: () => import('pages/01_branch-management/MainPage.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/personnel-management',
|
path: '/personnel-management',
|
||||||
name: 'PersonnelManagement',
|
name: 'PersonnelManagement',
|
||||||
|
beforeEnter: (to, from, next) => {
|
||||||
|
if (
|
||||||
|
isRoleInclude([
|
||||||
|
'admin',
|
||||||
|
'branch_admin',
|
||||||
|
'head_of_admin',
|
||||||
|
'system',
|
||||||
|
'owner',
|
||||||
|
])
|
||||||
|
) {
|
||||||
|
next();
|
||||||
|
} else {
|
||||||
|
next('/');
|
||||||
|
}
|
||||||
|
},
|
||||||
component: () => import('pages/02_personnel-management/MainPage.vue'),
|
component: () => import('pages/02_personnel-management/MainPage.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue