旅游教育出版社-数字教材移动端
litian
2025-06-27 187f70057558e0482e611131882451e0fedaf1cc
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
// 整合路由配置、路由拦截;(可扩展页面进度条)
 
import Vue from "vue";
import VueRouter from "vue-router";
// import myConfig from "@/assets/js/config";
 
// 路由数据
import routes from "./routes";
 
Vue.use(VueRouter);
 
const router = new VueRouter({
  routes
});
 
/**
 * 路由拦截
 * 权限验证
 */
// router.beforeEach((to, from, next) => {
//   // 验证路由是否需要有登录验证
//   if (to.matched.some(r => r.meta.requiresAuth)) {
//     // 这里暂时将localStorage里是否存有token作为验证是否登录的条件
//     // 请根据自身业务需要修改
//     const token = localStorage.getItem(myConfig.tokenName);
//     if (token && token !== "undefined") {
//       next();
//     } else {
//       // 验证不通过跳转到登录界面,将当前预计打开的页面完整地址传递至登录页面,登录后继续跳转
//       next({
//         name: "login",
//         query: {
//           redirect: to.fullPath
//         }
//       });
//     }
//   } else {
//     // 不需要身份校验 直接通过
//     next();
//   }
// });
 
export default router;