index.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { createRouter, createWebHashHistory, Router } from 'vue-router';
  2. import Auth from '@/views/layout/auth';
  3. const router: Router = createRouter({
  4. history: createWebHashHistory(),
  5. routes: [
  6. {
  7. path: '/',
  8. component: Auth,
  9. children: [
  10. {
  11. path: '/lessonCourseware',
  12. name: 'lessonCourseware',
  13. component: () => import('@/views/lessonCourseware/index'),
  14. meta: {
  15. title: '云课堂'
  16. }
  17. },
  18. {
  19. path: '/courseList',
  20. name: 'courseList',
  21. component: () => import('@/views/courseList/index'),
  22. meta: {
  23. title: '课件详情'
  24. }
  25. },
  26. {
  27. path: '/coursewarePlay',
  28. name: 'coursewarePlay',
  29. component: () => import('@/views/coursewarePlay'),
  30. meta: {
  31. title: '课程播放'
  32. }
  33. },
  34. {
  35. path: '/login',
  36. name: 'login',
  37. component: () => import('@/views/layout/login'),
  38. meta: {
  39. isRegister: false
  40. }
  41. }
  42. ]
  43. }
  44. ],
  45. scrollBehavior(to, form, savedPosition) {
  46. if (savedPosition) {
  47. return savedPosition;
  48. } else {
  49. return { left: 0, top: 0 };
  50. }
  51. }
  52. });
  53. // router.onError(error => {
  54. // if (error instanceof Error) {
  55. // const isChunkLoadFailed = error.name.indexOf('chunk');
  56. // const targetPath = router.currentRoute.value.fullPath;
  57. // console.log(error);
  58. // if (isChunkLoadFailed) {
  59. // location.hash = targetPath;
  60. // window.location.reload();
  61. // }
  62. // }
  63. // });
  64. export default router;