index.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const Router = VueRouter;
  2. import Layout from "@/layout";
  3. const routes = [
  4. //默认跳转到登录页
  5. {
  6. path: "/",
  7. redirect: "/loadingPage",
  8. },
  9. //loading
  10. {
  11. path: "/loadingPage",
  12. component: () => import("@/views/loadingPage/index"),
  13. hidden: true,
  14. },
  15. //登录页
  16. {
  17. path: "/login",
  18. component: () => import("@/views/login/index"),
  19. hidden: true,
  20. },
  21. //忘记密码
  22. {
  23. path: "/forget-password",
  24. component: () => import("@/views/login/forget-password"),
  25. hidden: true,
  26. noCache: true,
  27. },
  28. {
  29. path: "/404",
  30. component: () => import("@/views/error-page/404"),
  31. hidden: false,
  32. noCache: true,
  33. },
  34. {
  35. path: "*",
  36. redirect: "/404",
  37. },
  38. ];
  39. console.log(process.env.BASE_URL);
  40. const router = new Router({
  41. mode: "hash",
  42. base: process.env.BASE_URL,
  43. scrollBehavior: () => ({ y: 0 }),
  44. routes,
  45. });
  46. // 重写路由的push方法,主要是为了解决同一个路由路径重复点击报错
  47. const routerPush = Router.prototype.push;
  48. Router.prototype.push = function push(location) {
  49. return routerPush.call(this, location).catch((error) => error);
  50. };
  51. Vue.use(Router);
  52. export default router;