From c6a9b11ff0783bcd81a043a179fbc27f685eee70 Mon Sep 17 00:00:00 2001
From: lxl <lixuliang_hd@126.com>
Date: 星期一, 07 十一月 2022 16:19:43 +0800
Subject: [PATCH] 菜单

---
 src/router/index.js |   91 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 88 insertions(+), 3 deletions(-)

diff --git a/src/router/index.js b/src/router/index.js
index 01e68dd..f07342e 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -1,5 +1,6 @@
 import Vue from 'vue';
 import VueRouter from 'vue-router';
+import { getToken } from '@/utils/auth'; // get token from cookie
 import Home from '../views/Home.vue';
 import login from '../components/login';
 import Synthesis from '../views/Synthesis/index.vue'; //缁煎悎灞曠ず
@@ -26,6 +27,7 @@
 import SpatialData from '../views/datamanage/SpatialData.vue'; //鏁版嵁绠$悊-绌洪棿鏁版嵁
 import versionManage from '../views/datamanage/versionManage.vue'; //鏁版嵁绠$悊-鐗堟湰绠$悊
 import dictionaryManage from '../views/datamanage/dictionaryManage.vue'; //鏁版嵁绠$悊-瀛楀吀绠$悊
+import domainManage from '../views/datamanage/domainManage.vue'; //鏁版嵁绠$悊-鍊煎煙绠$悊
 import styleManage from '../views/datamanage/styleManage.vue'; //鏁版嵁绠$悊-鏍峰紡绠$悊
 import addStyle from '../views/datamanage/addStyle.vue'; //鏁版嵁绠$悊-鏍峰紡绠$悊-娣诲姞鏍峰紡
 
@@ -35,20 +37,33 @@
 import roleManage from '../views/userManage/roleManage.vue'; // 鐢ㄦ埛绠$悊妯″潡
 import groupManage from '../views/userManage/groupManage.vue'; // 鐢ㄦ埛绠$悊妯″潡
 import authorityManage from '@/views/userManage/authorityManage.vue'; //鐢ㄦ埛绠$悊-鏉冮檺绠$悊
+import resourceManage from '@/views/userManage/resourceManage.vue'; //鐢ㄦ埛绠$悊-璧勬簮绠$悊
+import userRoleAuthorization from '@/views/AuthorizationManagement/userRoleAuthorization.vue'; //绯荤粺绠$悊-鐢ㄦ埛瑙掕壊鎺堟潈
+
+import menuRoleAuthorization from '@/views/AuthorizationManagement/menuRoleAuthorization.vue'; //绯荤粺绠$悊-鑿滃崟鏉冮檺鎺堟潈
+import roleResAuthorization from '@/views/AuthorizationManagement/roleResAuthorization.vue'; //绯荤粺绠$悊-瑙掕壊璧勬簮鎺堟潈
+import roleMenuAuthorization from '@/views/AuthorizationManagement/roleMenuAuthorization.vue'; //绯荤粺绠$悊-瑙掕壊鑿滃崟鎺堟潈
+
+const originalPush = VueRouter.prototype.push;
+
+VueRouter.prototype.push = function push(location) {
+  return originalPush.call(this, location).catch((err) => err);
+};
 
 // 缇ょ粍绠$悊
 Vue.use(VueRouter);
 
 const routes = [
   {
-    path: '/',
+    path: '/login',
     name: 'login',
     component: login,
   },
   {
-    path: '/Home',
+    path: '/',
     name: 'Home',
     component: Home,
+    redirect: '/Synthesis',
     children: [
       {
         path: '/Synthesis',
@@ -139,6 +154,15 @@
         name: 'dictionaryManage',
         meta: {
           title: '瀛楀吀绠$悊',
+          requireAuth: true, // 鏍囪瘑璇ヨ矾鐢辨槸鍚﹂渶瑕佺櫥褰�
+        },
+      },
+      {
+        path: '/domainManage',
+        component: domainManage,
+        name: 'domainManage',
+        meta: {
+          title: '鍊煎煙绠$悊',
           requireAuth: true, // 鏍囪瘑璇ヨ矾鐢辨槸鍚﹂渶瑕佺櫥褰�
         },
       },
@@ -326,6 +350,51 @@
           requireAuth: true, // 鏍囪瘑璇ヨ矾鐢辨槸鍚﹂渶瑕佺櫥褰�
         },
       },
+      {
+        path: '/resourceManage',
+        component: resourceManage,
+        name: 'resourceManage',
+        meta: {
+          title: '璧勬簮绠$悊',
+          requireAuth: true, // 鏍囪瘑璇ヨ矾鐢辨槸鍚﹂渶瑕佺櫥褰�
+        },
+      },
+      {
+        path: '/userRoleAuthorization',
+        component: userRoleAuthorization,
+        name: 'userRoleAuthorization',
+        meta: {
+          title: '鐢ㄦ埛瑙掕壊鎺堟潈',
+          requireAuth: true, // 鏍囪瘑璇ヨ矾鐢辨槸鍚﹂渶瑕佺櫥褰�
+        },
+      },
+      {
+        path: '/menuRoleAuthorization',
+        component: menuRoleAuthorization,
+        name: 'menuRoleAuthorization',
+        meta: {
+          title: '鑿滃崟鏉冮檺鎺堟潈',
+          requireAuth: true, // 鏍囪瘑璇ヨ矾鐢辨槸鍚﹂渶瑕佺櫥褰�
+        },
+      },
+      {
+        path: '/roleResAuthorization',
+        component: roleResAuthorization,
+        name: 'roleResAuthorization',
+        meta: {
+          title: '鑿滃崟鏉冮檺鎺堟潈',
+          requireAuth: true, // 鏍囪瘑璇ヨ矾鐢辨槸鍚﹂渶瑕佺櫥褰�
+        },
+      },
+      {
+        path: '/roleMenuAuthorization',
+        component: roleMenuAuthorization,
+        name: 'roleMenuAuthorization',
+        meta: {
+          title: '鑿滃崟鏉冮檺鎺堟潈',
+          requireAuth: true, // 鏍囪瘑璇ヨ矾鐢辨槸鍚﹂渶瑕佺櫥褰�
+        },
+      },
     ],
   },
 ];
@@ -333,5 +402,21 @@
 const router = new VueRouter({
   routes,
 });
-
+//璺敱瀹堝崼
+router.beforeEach((to, from, next) => {
+  next();
+  if (to.matched.some((auth) => auth.meta.requireAuth)) {
+    // 鑾峰彇token
+    let token = getToken();
+    if (token) {
+      next();
+    } else {
+      next({
+        path: '/login',
+      });
+    }
+  } else {
+    next();
+  }
+});
 export default router;

--
Gitblit v1.9.3