燕山石化溯源三维电子沙盘-【前端】-Web
WX
2023-08-01 0d0582cc5352a60e5f7042df81e6153e70a9715e
src/router/index.js
@@ -1,26 +1,64 @@
import { createRouter, createWebHashHistory } from "vue-router";
import Home from "../views/Home.vue";
import {
  createRouter,
  createWebHashHistory,
  createWebHistory,
} from "vue-router";
import http from "../http.js";
import index from "@/views/index.vue";
import NotFound from "@/views/NotFound.vue";
const routes = [
  {
    path: "/",
    name: "Home",
    component: Home,
    component: index,
    meta: {
      title: "首页",
      requireAuth: true, // 标识该路由是否需要登录
    },
  },
  {
    path: "/about",
    name: "About",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/About.vue"),
    path: "/NotFound",
    name: "NotFound",
    component: NotFound,
  },
];
const router = createRouter({
  history: createWebHashHistory(),
  // history: createWebHistory(),
  routes,
});
//路由守卫
router.beforeEach(async (to, from, next) => {
  if (to.path == "/") {
    next();
    // var url = window.location.href;
    // var url = window.location.href;
    // var num = url.indexOf("?");
    // if (num != -1) {
    //   const dt = await http.get(getTokenUrl);
    //   console.log(dt);
    // }
    // if (num == -1) {
    //   // next("/NotFound");
    //   alert("无权限访问,请联系管理员");
    //   // return;
    // } else {
    //   next();
    //   const dt = await http.get(getTokenUrl);
    //   console.log(dt);
    //   // if (dt.status_code !== 200) {
    //   //   // next("/NotFound");
    //   //   alert("无权限访问,请联系管理员");
    //   // } else {
    //   //   next("/");
    //   // }
    // }
  } else {
    next();
  }
});
export default router;