月球大数据地理空间分析展示平台-【前端】-月球2期前端
WX
2023-06-07 fc1f22df5322aa89ffcf60040b01eff0451df3a3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
 
// 登录页
import Login from "../views/login.vue";
//首页
import Index from "../views/Index.vue";
const routes: Array<RouteRecordRaw> = [
  {
    path: "/Login",
    name: "Login",
    component: Login,
  },
  {
    path: "/",
    name: "Index",
    component: Index,
    meta: {
      title: "首页",
      requireAuth: true, // 标识该路由是否需要登录
    },
  },
];
 
const router = createRouter({
  history: createWebHashHistory(),
  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;