router.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import Vue from 'vue';
  2. import Router from 'vue-router';
  3. import { getAuth } from '@/utils/auth';
  4. import { getGuide } from '@/utils/guide';
  5. import {
  6. getTenantCode, getSystemConfig,
  7. getUserIcon, shitiStatusControl,
  8. saveHistoryPaths,
  9. } from '@/utils/common';
  10. Vue.use(Router);
  11. const router = new Router({
  12. mode: 'history',
  13. base: process.env.BASE_URL,
  14. routes: [
  15. {
  16. path: '/',
  17. redirect: '/index',
  18. },
  19. {
  20. name: '首页',
  21. path: '/index',
  22. component: () => {
  23. return import(/* webpackChunkName: "index" */ './views/client/Index.vue');
  24. },
  25. },
  26. {
  27. name: '课程开发',
  28. path: '/courseDev',
  29. component: () => {
  30. return import(/* webpackChunkName: "index" */ './views/client/CourseDev.vue');
  31. },
  32. },
  33. {
  34. name: 'Login',
  35. path: '/login',
  36. component: () => {
  37. return import(/* webpackChunkName: "Login" */ './views/management/Login/index.vue');
  38. },
  39. },
  40. {
  41. name: 'admin',
  42. path: '/admin',
  43. meta: {
  44. icon: "el-icon-platform-eleme",
  45. title: "页面管理"
  46. },
  47. isAdminMenu: true,
  48. component: () => {
  49. return import(/* webpackChunkName: "Home" */ './views/management/Home/index.vue');
  50. },
  51. children: [
  52. {
  53. path: '/hangyezixun',
  54. name: 'hangyezixun',
  55. meta: {
  56. icon: "",
  57. title: "行业资讯"
  58. },
  59. isAdminMenu: true,
  60. component: () => {
  61. return import(/* webpackChunkName: "Home" */ './views/management/HangYeZiXun/index.vue');
  62. },
  63. },
  64. ],
  65. },
  66. ],
  67. });
  68. function dispatchScss(path) {
  69. if (!path) {
  70. return;
  71. }
  72. if (path.indexOf('/a/') > -1) {
  73. require('@/assets/css/main/main-a.scss');
  74. } else if (path.indexOf('/c/') > -1) {
  75. require('@/assets/css/main/main-c.scss');
  76. } else {
  77. require('@/assets/css/main/main-z.scss');
  78. }
  79. }
  80. router.beforeEach((to, from, next) => {
  81. dispatchScss(to.fullPath);
  82. getAuth();
  83. getGuide();
  84. // getTenantCode();
  85. getSystemConfig();
  86. if (getSystemConfig()) {
  87. document.title = getSystemConfig().logoText; // describe: 更改title(刷新问题待优化) author: Wgy date:2019-12-04
  88. }
  89. //个人头像
  90. getUserIcon();
  91. shitiStatusControl(to);
  92. saveHistoryPaths(to, from, next);
  93. next();
  94. });
  95. export default router;