routes.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. import {
  2. HOME,
  3. LOGIN,
  4. REGISTER,
  5. STUDENT,
  6. STUDENT_COURSE,
  7. TEACHER,
  8. TEACHER_COURSE
  9. } from "@/router/name";
  10. import { judgeLogin } from "@/util/auth";
  11. import { getUserProfile } from "@/util/profileStorage";
  12. export default [
  13. {
  14. path: "/login",
  15. component: () => import("@/layouts/LoginLayout"),
  16. meta: { requiresAuth: false },
  17. children: [
  18. {
  19. name: REGISTER,
  20. path: "/register",
  21. component: () => import("@/views/login/Register.vue")
  22. },
  23. {
  24. name: LOGIN,
  25. path: "",
  26. component: () => import("@/views/login/Login.vue")
  27. }
  28. ]
  29. },
  30. {
  31. path: "/teacher",
  32. component: () => import("@/layouts/HomeLayout"),
  33. meta: { requiresAuth: false },
  34. children: [
  35. {
  36. name: TEACHER,
  37. path: "",
  38. component: () => import("@/views/teacher/Home")
  39. },
  40. {
  41. path: "setting",
  42. component: () => import("@/layouts/SettingLayout"),
  43. children: [
  44. {
  45. path: "profile",
  46. component: () => import("@/views/setting/Profile")
  47. },
  48. {
  49. path: "password",
  50. component: () => import("@/views/setting/Password")
  51. }
  52. ]
  53. }
  54. ]
  55. },
  56. {
  57. path: "/course-teacher/:courseId",
  58. component: () => import("@/layouts/courseLayouts/TeacherCourseLayout.vue"),
  59. meta: { requiresAuth: false },
  60. children: [
  61. {
  62. name: TEACHER_COURSE,
  63. path: "dashboard",
  64. component: () => import("@/views/teacher/Dashboard")
  65. },
  66. {
  67. path: "question",
  68. component: () => import("@/views/teacher/Question")
  69. },
  70. {
  71. path: "question/:id",
  72. component: () => import("@/views/teacher/Question/questionDetail.vue")
  73. },
  74. {
  75. path: "result",
  76. component: () => import("@/views/teacher/Result")
  77. },
  78. {
  79. path: "code",
  80. component: () => import("@/views/teacher/Code/index")
  81. },
  82. {
  83. path: "code/:codeId",
  84. component: () => import("@/views/teacher/Code/detail")
  85. },
  86. {
  87. path: "code/:codeId/test",
  88. component: () => import("@/views/teacher/Code/test")
  89. },
  90. {
  91. path: "document",
  92. component: () => import("@/views/teacher/Document/index")
  93. },
  94. {
  95. path: "document/:documentId",
  96. component: () => import("@/views/teacher/Document/detail")
  97. },
  98. {
  99. path: "document/:documentId/content",
  100. component: () => import("@/views/teacher/Document/docContent")
  101. },
  102. {
  103. path: "review",
  104. component: () => import("@/views/teacher/Review")
  105. },
  106. {
  107. path: "review/:reviewId",
  108. component: () => import("@/views/teacher/Review/ReviewDetail"),
  109. children: [
  110. {
  111. path: "",
  112. component: () =>
  113. import("@/views/teacher/Review/ReviewDetail/Detail")
  114. },
  115. {
  116. path: "groups",
  117. component: () =>
  118. import("@/views/teacher/Review/ReviewDetail/Groups")
  119. }
  120. ]
  121. },
  122. {
  123. path: "review/:reviewId/groups/:groupId",
  124. component: () =>
  125. import("@/views/teacher/Review/ReviewDetail/GroupDocDetail")
  126. },
  127. {
  128. path: "review/:reviewId/groups/:groupId/argue",
  129. component: () =>
  130. import("@/views/teacher/Review/ReviewDetail/GroupArgueDetail")
  131. }
  132. ]
  133. },
  134. {
  135. path: "/course-student/:courseId",
  136. component: () => import("@/layouts/courseLayouts/StudentCourseLayout.vue"),
  137. meta: { requiresAuth: false },
  138. children: [
  139. {
  140. name: STUDENT_COURSE,
  141. path: "dashboard",
  142. component: () => import("@/views/student/Dashboard")
  143. },
  144. {
  145. path: "code",
  146. component: () => import("@/views/student/Code/index")
  147. },
  148. {
  149. path: "code/:homeworkId",
  150. component: () => import("@/views/student/Code/ProjectList/index")
  151. },
  152. {
  153. path: "code/:homeworkId/:projectId",
  154. component: () => import("@/views/student/Code/ProjectDetail/index"),
  155. children: [
  156. {
  157. path: "",
  158. component: () =>
  159. import("@/views/student/Code/ProjectDetail/BuildDetail")
  160. },
  161. {
  162. path: "deploy",
  163. component: () =>
  164. import("@/views/student/Code/ProjectDetail/DeployDetail")
  165. },
  166. {
  167. path: "test",
  168. component: () =>
  169. import("@/views/student/Code/ProjectDetail/TestDetail")
  170. }
  171. ]
  172. },
  173. {
  174. path: "code/:homeworkId/:projectId/test/unit/:unitTestId",
  175. component: () =>
  176. import("@/views/student/Code/ProjectDetail/Test/UnitTestDetail")
  177. },
  178. {
  179. path: "code/:homeworkId/:projectId/test/functional/:functionalTestId",
  180. component: () =>
  181. import("@/views/student/Code/ProjectDetail/Test/FunctionalTestDetail")
  182. },
  183. {
  184. path: "document",
  185. component: () => import("@/views/student/Document/index")
  186. },
  187. {
  188. path: "document/:documentId",
  189. component: () => import("@/views/student/Document/detail")
  190. },
  191. {
  192. path: "review",
  193. component: () => import("@/views/student/Review")
  194. },
  195. {
  196. path: "review/:reviewId",
  197. component: () => import("@/views/student/Review/ReviewDetail"),
  198. children: [
  199. {
  200. path: "self",
  201. component: () =>
  202. import("@/views/student/Review/ReviewDetail/ReviewSelfDetail")
  203. },
  204. {
  205. path: "",
  206. component: () =>
  207. import("@/views/student/Review/ReviewDetail/ReviewDocs")
  208. }
  209. ]
  210. },
  211. {
  212. path: "review/:reviewId/doc/:docReviewId",
  213. component: () => import("@/views/student/Review/ReviewDocDetail")
  214. },
  215. {
  216. path: "code",
  217. component: () => import("@/views/student/Code")
  218. },
  219. {
  220. path: "group",
  221. component: () => import("@/views/student/Group")
  222. }
  223. ]
  224. },
  225. {
  226. path: "/student",
  227. component: () => import("@/layouts/HomeLayout"),
  228. meta: { requiresAuth: false },
  229. children: [
  230. {
  231. name: STUDENT,
  232. path: "",
  233. component: () => import("@/views/student/Home")
  234. },
  235. {
  236. path: "setting",
  237. component: () => import("@/layouts/SettingLayout"),
  238. children: [
  239. {
  240. path: "profile",
  241. component: () => import("@/views/setting/Profile")
  242. },
  243. {
  244. path: "password",
  245. component: () => import("@/views/setting/Password")
  246. }
  247. ]
  248. }
  249. ]
  250. },
  251. {
  252. path: "/",
  253. name: HOME,
  254. redirect: () => {
  255. if (judgeLogin()) {
  256. const { role } = getUserProfile();
  257. return { name: role };
  258. } else {
  259. return { name: LOGIN };
  260. }
  261. }
  262. }
  263. ];