Browse Source

路由设置

gzb
wangzhonglu 10 months ago
parent
commit
cbfc0d6943

+ 53
- 48
src/router/index.js View File

@@ -1,5 +1,9 @@
1 1
 import Vue from "vue";
2 2
 import VueRouter from "vue-router";
3
+import platform from "./platform";
4
+import region from "./region";
5
+import school from "./school";
6
+
3 7
 Vue.use(VueRouter);
4 8
 function queryStorage(location) {
5 9
   if (location instanceof Object && location.path) {
@@ -39,7 +43,7 @@ const createRouter = () =>
39 43
       y: 0
40 44
     }),
41 45
     routes: [
42
-      /* {
46
+      {
43 47
         path: "/login",
44 48
         name: "login",
45 49
         component: () => import("@/views/login/login.vue"),
@@ -51,15 +55,15 @@ const createRouter = () =>
51 55
           // 路由名称
52 56
           title: "登录"
53 57
         }
54
-      }, */
58
+      },
55 59
       {
56 60
         path: "/",
57 61
         component: () => import("@/views/layout.vue"),
58
-        name: "layout"
59
-        // redirect: {
60
-        //   path: "/"
61
-        // },
62
-        // children: []
62
+        name: "layout",
63
+        redirect: {
64
+          path: "/platform"
65
+        },
66
+        children: [platform, region, school]
63 67
       }
64 68
     ]
65 69
   });
@@ -68,46 +72,47 @@ const router = createRouter();
68 72
  * 路由守卫(拦截)
69 73
  */
70 74
 router.beforeEach((to, from, next) => {
71
-  if (!to.meta.isAuth) {
72
-    next();
73
-  } else {
74
-    /**
75
-     * bi_userInfo 登录用户信息
76
-     * {content, datetime}
77
-     */
78
-    let _userInfo = localStorage.getItem("bi_userInfo");
79
-    if (_userInfo) {
80
-      _userInfo = JSON.parse(_userInfo) || {};
81
-      if (_userInfo.content) {
82
-        const bi_userInfo = _userInfo.content;
83
-        const datetime = _userInfo.datetime;
84
-        const nowtime = new Date().getTime();
85
-        let diff = nowtime - datetime;
86
-        if (bi_userInfo && diff < 1000 * 60 * 60 * 24) {
87
-          _userInfo.datetime = nowtime;
88
-          localStorage.setItem("bi_userInfo", JSON.stringify(_userInfo));
89
-          next();
90
-        } else {
91
-          console.log("文件名:router index.vue,退出原因:超过24小时未登录");
92
-          next({
93
-            path: "/login",
94
-            query: to.query
95
-          });
96
-        }
97
-      } else {
98
-        console.log("文件名:router index.vue,退出原因:userInfo不存在1");
99
-        next({
100
-          path: "/login",
101
-          query: to.query
102
-        });
103
-      }
104
-    } else {
105
-      console.log("文件名:router index.vue,退出原因:userInfo不存在2");
106
-      next({
107
-        path: "/login",
108
-        query: to.query
109
-      });
110
-    }
111
-  }
75
+  next();
76
+  // if (!to.meta.isAuth) {
77
+  //   next();
78
+  // } else {
79
+  //   /**
80
+  //    * ctr_userInfo 登录用户信息
81
+  //    * {content, datetime}
82
+  //    */
83
+  //   let _userInfo = localStorage.getItem("ctr_userInfo");
84
+  //   if (_userInfo) {
85
+  //     _userInfo = JSON.parse(_userInfo) || {};
86
+  //     if (_userInfo.content) {
87
+  //       const ctr_userInfo = _userInfo.content;
88
+  //       const datetime = _userInfo.datetime;
89
+  //       const nowtime = new Date().getTime();
90
+  //       let diff = nowtime - datetime;
91
+  //       if (ctr_userInfo && diff < 1000 * 60 * 60 * 24) {
92
+  //         _userInfo.datetime = nowtime;
93
+  //         localStorage.setItem("ctr_userInfo", JSON.stringify(_userInfo));
94
+  //         next();
95
+  //       } else {
96
+  //         console.log("文件名:router index.vue,退出原因:超过24小时未登录");
97
+  //         next({
98
+  //           path: "/login",
99
+  //           query: to.query
100
+  //         });
101
+  //       }
102
+  //     } else {
103
+  //       console.log("文件名:router index.vue,退出原因:userInfo不存在1");
104
+  //       next({
105
+  //         path: "/login",
106
+  //         query: to.query
107
+  //       });
108
+  //     }
109
+  //   } else {
110
+  //     console.log("文件名:router index.vue,退出原因:userInfo不存在2");
111
+  //     next({
112
+  //       path: "/login",
113
+  //       query: to.query
114
+  //     });
115
+  //   }
116
+  // }
112 117
 });
113 118
 export default router;

+ 25
- 0
src/router/platform.js View File

@@ -0,0 +1,25 @@
1
+export default {
2
+  path: "platform",
3
+  component: () => import("@/views/platform/index.vue"),
4
+  name: "platform",
5
+  meta: {
6
+    keepAlive: true,
7
+    isAuth: true,
8
+    title: "平台管控"
9
+  },
10
+  redirect: {
11
+    path: "/platform/home"
12
+  },
13
+  children: [
14
+    {
15
+      path: "home",
16
+      component: () => import("@/views/platform/home/index.vue"),
17
+      name: "home",
18
+      meta: {
19
+        keepAlive: true,
20
+        isAuth: true,
21
+        title: "平台管控-首页"
22
+      }
23
+    }
24
+  ]
25
+};

+ 25
- 0
src/router/region.js View File

@@ -0,0 +1,25 @@
1
+export default {
2
+  path: "region",
3
+  component: () => import("@/views/region/index.vue"),
4
+  name: "region",
5
+  meta: {
6
+    keepAlive: true,
7
+    isAuth: true,
8
+    title: "区域管控"
9
+  },
10
+  redirect: {
11
+    path: "/region/home"
12
+  },
13
+  children: [
14
+    {
15
+      path: "home",
16
+      component: () => import("@/views/region/home/index.vue"),
17
+      name: "home",
18
+      meta: {
19
+        keepAlive: true,
20
+        isAuth: true,
21
+        title: "区域管控-首页"
22
+      }
23
+    }
24
+  ]
25
+};

+ 25
- 0
src/router/school.js View File

@@ -0,0 +1,25 @@
1
+export default {
2
+  path: "school",
3
+  component: () => import("@/views/school/index.vue"),
4
+  name: "school",
5
+  meta: {
6
+    keepAlive: true,
7
+    isAuth: true,
8
+    title: "学校管控"
9
+  },
10
+  redirect: {
11
+    path: "/school/home"
12
+  },
13
+  children: [
14
+    {
15
+      path: "home",
16
+      component: () => import("@/views/school/home/index.vue"),
17
+      name: "home",
18
+      meta: {
19
+        keepAlive: true,
20
+        isAuth: true,
21
+        title: "学校管控-首页"
22
+      }
23
+    }
24
+  ]
25
+};

+ 7
- 7
src/utils/httpRequest.js View File

@@ -37,14 +37,14 @@ const http = axios.create({
37 37
 http.interceptors.request.use(
38 38
   (config) => {
39 39
     // 登录后校验账号
40
-    let bi_userInfo = localStorage.getItem("bi_userInfo");
41
-    if (bi_userInfo) {
42
-      bi_userInfo = JSON.parse(bi_userInfo).content;
43
-      if (bi_userInfo) {
44
-        config.headers["Token-Key"] = bi_userInfo.token_key;
45
-        config.headers["Token-Value"] = bi_userInfo.token_value;
40
+    let ctr_userInfo = localStorage.getItem("ctr_userInfo");
41
+    if (ctr_userInfo) {
42
+      ctr_userInfo = JSON.parse(ctr_userInfo).content;
43
+      if (ctr_userInfo) {
44
+        config.headers["Token-Key"] = ctr_userInfo.token_key;
45
+        config.headers["Token-Value"] = ctr_userInfo.token_value;
46 46
         // 验证登陆人
47
-        config.headers["XH-UserId"] = bi_userInfo.userid;
47
+        config.headers["XH-UserId"] = ctr_userInfo.userid;
48 48
       }
49 49
     }
50 50
     config.headers.st = window._config.secret;

+ 11
- 2
src/views/layout.vue View File

@@ -1,5 +1,7 @@
1 1
 <template>
2
-  <div class="layout_box"></div>
2
+  <div class="layout_wrap">
3
+    <router-view></router-view>
4
+  </div>
3 5
 </template>
4 6
 
5 7
 <script>
@@ -12,4 +14,11 @@ export default {
12 14
 };
13 15
 </script>
14 16
 
15
-<style lang="less" scoped></style>
17
+<style lang="less" scoped>
18
+.layout_wrap {
19
+  width: 100vw;
20
+  height: 100vh;
21
+  background-color: #f1f6fc;
22
+  overflow: auto;
23
+}
24
+</style>

+ 16
- 0
src/views/platform/index.vue View File

@@ -0,0 +1,16 @@
1
+<template>
2
+  <div>
3
+    <router-view></router-view>
4
+  </div>
5
+</template>
6
+
7
+<script>
8
+export default {
9
+  data() {
10
+    return {};
11
+  },
12
+  methods: {}
13
+};
14
+</script>
15
+
16
+<style lang="less" scoped></style>

+ 14
- 0
src/views/region/index.vue View File

@@ -0,0 +1,14 @@
1
+<template>
2
+  <div></div>
3
+</template>
4
+
5
+<script>
6
+export default {
7
+  data() {
8
+    return {};
9
+  },
10
+  methods: {}
11
+};
12
+</script>
13
+
14
+<style lang="less" scoped></style>

Loading…
Cancel
Save