index.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. import Vue from 'vue';
  2. import VueRouter from 'vue-router';
  3. import store from '@/store/index';
  4. Vue.use(VueRouter);
  5. const routes = [
  6. {
  7. path: '/',
  8. name: 'frame',
  9. component: () => import('@/views/index.vue'),
  10. children: [
  11. {
  12. path: '/list',
  13. name: 'test_list',
  14. component: () => import('@/views/test/list.vue'),
  15. },
  16. {
  17. path: '/detail',
  18. name: 'test_detail',
  19. component: () => import('@/views/test/detail.vue'),
  20. },
  21. {
  22. path: '/itembank/detail',
  23. name: 'itembank_detail',
  24. meta: { title: '题库', sub: '详情' },
  25. component: () => import('@/views/Itembank/detail.vue'),
  26. },
  27. {
  28. path: '/itembank/index',
  29. name: 'itembank_index',
  30. meta: { title: '题库', sub: '管理' },
  31. component: () => import('@/views/Itembank/index.vue'),
  32. },
  33. // {
  34. // path: '/questionstate/detail',
  35. // name: 'questionstate_detail',
  36. // meta: { title: '问卷状态', sub: '详情' },
  37. // component: () => import('@/views/questionstate/detail.vue'),
  38. // },
  39. {
  40. path: '/questionstate/index',
  41. name: 'questionstate_index',
  42. meta: { title: '问卷状态', sub: '管理' },
  43. component: () => import('@/views/questionstate/index.vue'),
  44. },
  45. {
  46. path: '/certificaate/index',
  47. name: 'certificaate_index',
  48. meta: { title: '证书', sub: '管理' },
  49. component: () => import('@/views/certificaate/index.vue'),
  50. },
  51. {
  52. path: '/certificaate/detail',
  53. name: 'certificaate_detail',
  54. meta: { title: '证书', sub: '详情' },
  55. component: () => import('@/views/certificaate/detail.vue'),
  56. },
  57. {
  58. path: '/certificaate/look',
  59. name: 'certificaate_look',
  60. meta: { title: '证书', sub: '打印' },
  61. component: () => import('@/views/certificaate/look.vue'),
  62. },
  63. {
  64. path: '/questionnaire/index',
  65. name: 'questionnaire_index',
  66. meta: { title: '问卷', sub: '管理' },
  67. component: () => import('@/views/questionnaire/index.vue'),
  68. },
  69. {
  70. path: '/questionnaire/detail',
  71. name: 'questionnaire_detail',
  72. meta: { title: '问卷', sub: '详情' },
  73. component: () => import('@/views/questionnaire/detail.vue'),
  74. },
  75. {
  76. path: '/teacher/detail',
  77. name: 'teacher_detail',
  78. meta: { title: '教师', sub: '详情' },
  79. component: () => import('@/views/teacher/detail.vue'),
  80. },
  81. {
  82. path: '/teacher/index',
  83. name: 'teacher_index',
  84. meta: { title: '教师', sub: '管理' },
  85. component: () => import('@/views/teacher/index.vue'),
  86. },
  87. {
  88. path: '/teacher/means',
  89. name: 'teacher_means',
  90. component: () => import('@/views/teacher/means.vue'),
  91. },
  92. {
  93. path: '/teacher/verify',
  94. name: 'teacher_verify',
  95. meta: { title: '教师', sub: '审核页' },
  96. component: () => import('@/views/teacher/verify.vue'),
  97. },
  98. {
  99. path: '/work/detail',
  100. name: 'work_detail',
  101. meta: { title: '作业', sub: '详情' },
  102. component: () => import('@/views/work/detail.vue'),
  103. },
  104. {
  105. path: '/work/index',
  106. name: 'work_index',
  107. meta: { title: '作业', sub: '管理' },
  108. component: () => import('@/views/work/index.vue'),
  109. },
  110. {
  111. path: '/work/look',
  112. name: 'work_look',
  113. meta: { title: '作业题', sub: '管理' },
  114. component: () => import('@/views/work/look.vue'),
  115. },
  116. {
  117. path: '/subject/index',
  118. name: 'subject_index',
  119. meta: { title: '科目', sub: '管理' },
  120. component: () => import('@/views/subject/index.vue'),
  121. },
  122. {
  123. path: '/subject/detail',
  124. name: 'subject_detail',
  125. meta: { title: '科目', sub: '详情' },
  126. component: () => import('@/views/subject/detail.vue'),
  127. },
  128. {
  129. path: '/director/index',
  130. name: 'director_index',
  131. meta: { title: '班主任', sub: '管理' },
  132. component: () => import('@/views/director/index.vue'),
  133. },
  134. {
  135. path: '/director/detail',
  136. name: 'director_detail',
  137. meta: { title: '班主任', sub: '详情' },
  138. component: () => import('@/views/director/detail.vue'),
  139. },
  140. {
  141. path: '/dept/index',
  142. name: 'dept_index',
  143. meta: { title: '部门', sub: '管理' },
  144. component: () => import('@/views/dept/index.vue'),
  145. },
  146. {
  147. path: '/dept/detail',
  148. name: 'dept_detail',
  149. meta: { title: '部门', sub: '详情' },
  150. component: () => import('@/views/dept/detail.vue'),
  151. },
  152. {
  153. path: '/duty/index',
  154. name: 'duty_index',
  155. meta: { title: '职责', sub: '说明' },
  156. component: () => import('@/views/duty/index.vue'),
  157. },
  158. {
  159. path: '/location/index',
  160. name: 'location_index',
  161. meta: { title: '地点', sub: '管理' },
  162. component: () => import('@/views/location/index.vue'),
  163. },
  164. {
  165. path: '/location/detail',
  166. name: 'location_detail',
  167. meta: { title: '地点', sub: '详情' },
  168. component: () => import('@/views/location/detail.vue'),
  169. },
  170. {
  171. path: '/bedroom/index',
  172. name: 'bedroom_index',
  173. meta: { title: '寝室', sub: '管理' },
  174. component: () => import('@/views/bedroom/index.vue'),
  175. },
  176. {
  177. path: '/bedroom/detail',
  178. name: 'bedroom_detail',
  179. meta: { title: '寝室', sub: '详情' },
  180. component: () => import('@/views/bedroom/detail.vue'),
  181. },
  182. {
  183. path: '/classes/index',
  184. name: 'classes_index',
  185. meta: { title: '班级', sub: '管理' },
  186. component: () => import('@/views/classes/index.vue'),
  187. },
  188. {
  189. path: '/classes/detail',
  190. name: 'classes_detail',
  191. meta: { title: '班级', sub: '详情' },
  192. component: () => import('@/views/classes/detail.vue'),
  193. },
  194. {
  195. path: '/student/index',
  196. name: 'student_index',
  197. meta: { title: '学生', sub: '管理' },
  198. component: () => import('@/views/student/index.vue'),
  199. },
  200. {
  201. path: '/student/detail',
  202. name: 'student_detail',
  203. meta: { title: '学生', sub: '详情' },
  204. component: () => import('@/views/student/detail.vue'),
  205. },
  206. {
  207. path: '/plan/index',
  208. name: 'plan_index',
  209. meta: { title: '计划', sub: '管理' },
  210. component: () => import('@/views/plan/index.vue'),
  211. },
  212. {
  213. path: '/plan/detail',
  214. name: 'plan_detail',
  215. meta: { title: '计划', sub: '详情' },
  216. component: () => import('@/views/plan/detail.vue'),
  217. },
  218. {
  219. path: '/plan/classes',
  220. name: 'plan_classes',
  221. meta: { title: '安排', sub: '班级' },
  222. component: () => import('@/views/plan/classes.vue'),
  223. },
  224. {
  225. path: '/plan/lesson',
  226. name: 'plan_lesson',
  227. meta: { title: '安排', sub: '课程' },
  228. component: () => import('@/views/plan/lesson.vue'),
  229. },
  230. {
  231. path: '/plan/msg',
  232. name: 'plan_msg',
  233. meta: { title: '发送', sub: '通知' },
  234. component: () => import('@/views/plan/msg.vue'),
  235. },
  236. {
  237. path: '/plan/question',
  238. name: 'plan_question',
  239. meta: { title: '问卷', sub: '管理' },
  240. component: () => import('@/views/plan/question.vue'),
  241. },
  242. ],
  243. },
  244. {
  245. path: '/yearPlan/index',
  246. name: 'yearPlan_index',
  247. meta: { title: '全年计划', sub: '管理' },
  248. component: () => import('@/views/yearPlan/index.vue'),
  249. },
  250. ];
  251. const router = new VueRouter({
  252. mode: 'history',
  253. base: process.env.NODE_ENV === 'development' ? '' : process.env.VUE_APP_ROOT_URL + 'center',
  254. routes,
  255. });
  256. router.beforeEach((to, form, next) => {
  257. store.commit('setUser');
  258. let user = store.state.user;
  259. if (user) {
  260. if (user.type == process.env.VUE_APP_USER_TYPE) {
  261. console.log('缓存登陆');
  262. next();
  263. } else {
  264. console.error('非当前端用户,需要重新登陆');
  265. // next('/login'); //TODO 跳转至登陆页
  266. }
  267. }
  268. //下面是没登录的情况,需要跳转页面到用户未登录页
  269. else next();
  270. });
  271. export default router;