index.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. import Vue from 'vue';
  2. import Router from 'vue-router';
  3. //懒加载
  4. const App = () => import(/* webpackChunkName: "group-app"*/'@/App');
  5. const Index = () => import(/* webpackChunkName: "group-app"*/'@/login/Index');
  6. const NotFound = () => import(/* webpackChunkName: "group-app"*/'@/NotFound');
  7. const MainPage = () => import(/* webpackChunkName: "group-mainPage"*/'@/components/MainPage');
  8. const Home = () => import(/* webpackChunkName: "group-mainPage"*/'@/components/MainPage/Home');
  9. const AbilityTest = () => import(/* webpackChunkName: "group-mainPage"*/'@/components/MainPage/AbilityTest');
  10. const News = () => import(/* webpackChunkName: "group-mainPage"*/'@/components/MainPage/News');
  11. const AboutUs = () => import(/* webpackChunkName: "group-mainPage"*/'@/components/MainPage/AboutUs');
  12. const ContactUs = () => import(/* webpackChunkName: "group-mainPage"*/'@/components/MainPage/ContactUs');
  13. const ExamTable = () => import(/* webpackChunkName: "group-mainPage"*/'@/components/MainPage/ExamTable');
  14. const UserPage = () => import(/* webpackChunkName: "group-mainPage"*/'@/components/UserPage');
  15. const DoTest = () => import(/* webpackChunkName: "group-doTest"*/'@/components/doTest/DoTest.vue');
  16. const RestPage = () => import(/* webpackChunkName: "group-doTest"*/'@/components/doTest/RestPage');
  17. const TestResult = () => import(/* webpackChunkName: "group-doTest"*/'@/components/doTest/TestResult2');
  18. const GuidePage = () => import(/* webpackChunkName: "group-doTest"*/'@/components/doTest/GuidePage');
  19. const ControlApp = () => import(/* webpackChunkName: "group-controlApp"*/'@/ControlApp');
  20. const ControlMainPage = () => import(/* webpackChunkName: "group-controlApp"*/'@/components/ControlMainPage');
  21. const PaperList = () => import(/* webpackChunkName: "group-controlApp"*/'@/components/controlMainPage/PaperList');
  22. const PaperListSimple = () => import(/* webpackChunkName: "group-controlApp"*/'@/components/controlMainPage/PaperListSimple');
  23. const DocList = () => import(/* webpackChunkName: "group-controlApp"*/'@/components/controlMainPage/DocList');
  24. const QuestionList = () => import(/* webpackChunkName: "group-controlApp"*/'@/components/controlMainPage/docList/QuestionList');
  25. const UserList = () => import(/* webpackChunkName: "group-controlApp"*/'@/components/controlMainPage/UserList');
  26. const FirstEdition = () => import(/* webpackChunkName: "group-controlApp"*/'@/components/report/FirstEdition');
  27. const PDFTest = () => import(/* webpackChunkName: "group-controlApp"*/'@/components/report/PDFTest');
  28. // const CheckTable = () => import(/* webpackChunkName: "group-controlApp"*/'@/components/report/CheckTable');
  29. // const Knowledge = () => import(/* webpackChunkName: "group-controlApp"*/'@/components/report/Knowledge');
  30. const SimpleReport = () => import(/* webpackChunkName: "group-controlApp"*/'@/components/report/SimpleReport');
  31. const ControlLogin = () => import(/* webpackChunkName: "group-controlApp"*/'@/login/ControlLogin');
  32. const VoiceTest = () => import(/* webpackChunkName: "group-controlApp"*/'@/components/VoiceTest');
  33. const UserTest = () => import(/* webpackChunkName: "group-controlApp"*/'@/components/UserTest');
  34. import store from '@/store/index';
  35. import { getLoginUser } from '@/api/login'
  36. Vue.use(Router);
  37. export default new Router({
  38. routes: [{
  39. path: '/',
  40. redirect: { name: 'App' },
  41. },{
  42. path: '/app',
  43. name: 'App',
  44. component: App,
  45. beforeEnter: (to, from, next) => {
  46. getLoginUser().then(data => {
  47. store.dispatch('setLoginUser', data);
  48. next();
  49. }).catch(() => {
  50. next({name: 'Index'});
  51. })
  52. },
  53. redirect: { name: 'MainPage' },
  54. children: [{
  55. path: 'mainPage',
  56. name: 'MainPage',
  57. component: MainPage,
  58. redirect: { name: 'AbilityTest' },
  59. children: [{
  60. path: 'home',
  61. name: 'Home',
  62. component: Home
  63. }, {
  64. path: 'abilityTest',
  65. name: 'AbilityTest',
  66. component: AbilityTest,
  67. }, {
  68. path: 'news',
  69. name: 'News',
  70. component: News,
  71. }, {
  72. path: 'aboutUs',
  73. name: 'AboutUs',
  74. component: AboutUs,
  75. }, {
  76. path: 'contactUs',
  77. name: 'ContactUs',
  78. component: ContactUs,
  79. }, {
  80. path: 'examTable',
  81. name: 'ExamTable',
  82. component: ExamTable,
  83. }],
  84. },{
  85. path: 'userPage',
  86. name: 'UserPage',
  87. component: UserPage,
  88. },{
  89. path: 'guidePage/:examId',
  90. name: 'GuidePage',
  91. component: GuidePage
  92. },{
  93. path: 'doTest/:examId',
  94. name: 'DoTest',
  95. component: DoTest
  96. },{
  97. path: 'restPage/:examId',
  98. name: 'RestPage',
  99. component: RestPage
  100. },{
  101. // path: 'testResult/:result/:totalScore/:pid/:uid',
  102. path: 'testResult/:pid/:uid',
  103. name: 'TestResult',
  104. component: TestResult
  105. }]
  106. },
  107. {
  108. path: '/index',
  109. name: 'Index',
  110. component: Index
  111. },
  112. {
  113. path: '*',
  114. name: 'NotFound',
  115. component: NotFound
  116. },{
  117. path: '/ctrlApp',
  118. name: 'ControlApp',
  119. component: ControlApp,
  120. beforeEnter: (to, from, next) => {
  121. getLoginUser().then(data => {
  122. store.dispatch('setLoginUser', data);
  123. next();
  124. }).catch(() => {
  125. next({name: 'ControlLogin'});
  126. })
  127. },
  128. redirect: { name: 'ControlMainPage' },
  129. children: [{
  130. path: 'ctrlMainPage',
  131. name: 'ControlMainPage',
  132. component: ControlMainPage,
  133. redirect: { name: 'PaperListSimple' },
  134. children: [{
  135. path: 'paperList',
  136. name: 'PaperList',
  137. component: PaperList,
  138. },{
  139. path: 'paperListSimple',
  140. name: 'PaperListSimple',
  141. component: PaperListSimple,
  142. },{
  143. path: 'userList',
  144. name: 'UserList',
  145. component: UserList,
  146. },{
  147. path: 'docList',
  148. name: 'DocList',
  149. component: DocList,
  150. },{
  151. path: 'questionList/:pid',
  152. name: 'QuestionList',
  153. component: QuestionList
  154. }],
  155. },{
  156. path: 'firstEdition/:pid/:uid',
  157. name: 'FirstEdition',
  158. component: FirstEdition,
  159. },{
  160. path: 'pdfTest',
  161. name: 'PDFTest',
  162. component: PDFTest,
  163. },{
  164. path: 'simpleReport/:pid/:uid',
  165. name: 'SimpleReport',
  166. component: SimpleReport,
  167. }]
  168. },{
  169. path: '/ctrlLogin',
  170. name: 'ControlLogin',
  171. component: ControlLogin,
  172. },{
  173. path: '/voice',
  174. name: 'VoiceTest',
  175. component: VoiceTest,
  176. },{
  177. path: '/xxx',
  178. name: 'UserTest',
  179. component: UserTest,
  180. }]
  181. });