material.js 716 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. import { MATERIALMenu } from "../config/menu";
  4. Vue.use(Router)
  5. const originalPush = Router.prototype.push
  6. Router.prototype.push = function push (location) {
  7. return originalPush.call(this, location).catch(err => err)
  8. }
  9. let routes = [];
  10. MATERIALMenu.forEach(item => {
  11. routes.push({
  12. name: item.name,
  13. path: `${item.link}`,
  14. meta: {
  15. belong: item.belong
  16. },
  17. component: () => import(`../views/material/${item.name}/index.vue`)
  18. });
  19. });
  20. const router = new Router({
  21. routes: routes
  22. })
  23. router.beforeEach(async (to, from, next) => {
  24. if (to.path == '/') {
  25. return next({path: "/works" })
  26. }
  27. next()
  28. })
  29. export default router;