index.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. import Vue from 'vue'
  2. import VueRouter from 'vue-router'
  3. import { Message } from 'element-ui'
  4. Vue.use(VueRouter)
  5. // 2.创建路由对象
  6. const router = new VueRouter({
  7. routes: [
  8. {
  9. name: 'default',
  10. path: '/',
  11. redirect: { name: 'layout' }
  12. },
  13. // 4.配置单个路由
  14. {
  15. name: 'login',
  16. path: '/login',
  17. component: () => import('@/views/login/index.vue')
  18. },
  19. {
  20. name: 'layout',
  21. path: '/layout',
  22. component: () => import('@/views/layout/index.vue'),
  23. redirect: { name: 'home' },
  24. // 首页添加子路由
  25. children: [
  26. {
  27. name: 'home',
  28. path: 'home',
  29. meta: { myInd: 0 },
  30. component: () => import('@/views/home/index.vue')
  31. },
  32. {
  33. name: 'homeNews',
  34. path: 'homeNews/:id',
  35. meta: { myInd: 0 },
  36. component: () => import('@/views/home/News.vue')
  37. },
  38. // 馆藏管理
  39. {
  40. name: 'holding0',
  41. path: 'holding0',
  42. meta: { myInd: 1 },
  43. component: () => import('@/views/holding/holding0.vue')
  44. },
  45. {
  46. name: 'holding0_add',
  47. path: 'holding0_add',
  48. meta: { myInd: 1 },
  49. component: () => import('@/views/holding/holding0_add.vue')
  50. },
  51. {
  52. name: 'holding0_audit',
  53. path: 'holding0_audit',
  54. meta: { myInd: 1 },
  55. component: () => import('@/views/holding/holding0_audit.vue')
  56. },
  57. {
  58. name: 'holding0_result',
  59. path: 'holding0_result',
  60. meta: { myInd: 1 },
  61. component: () => import('@/views/holding/holding0_result.vue')
  62. },
  63. {
  64. name: 'holding1',
  65. path: 'holding1',
  66. meta: { myInd: 1 },
  67. component: () => import('@/views/holding/holding1.vue')
  68. },
  69. {
  70. name: 'holding1_look',
  71. path: 'holding1_look',
  72. meta: { myInd: 1 },
  73. component: () => import('@/views/holding/holding1_look.vue')
  74. },
  75. {
  76. name: 'holding1_audit',
  77. path: 'holding1_audit',
  78. meta: { myInd: 1 },
  79. component: () => import('@/views/holding/holding1_audit.vue')
  80. },
  81. {
  82. name: 'holding1_add',
  83. path: 'holding1_add',
  84. meta: { myInd: 1 },
  85. component: () => import('@/views/holding/holding1_add.vue')
  86. },
  87. {
  88. name: 'holding2',
  89. path: 'holding2',
  90. meta: { myInd: 1 },
  91. component: () => import('@/views/holding/holding2.vue')
  92. },
  93. {
  94. name: 'holding2_add',
  95. path: 'holding2_add',
  96. meta: { myInd: 1 },
  97. component: () => import('@/views/holding/holding2_add.vue')
  98. },
  99. {
  100. name: 'holding2_audit',
  101. path: 'holding2_audit',
  102. meta: { myInd: 1 },
  103. component: () => import('@/views/holding/holding2_audit.vue')
  104. },
  105. {
  106. name: 'holding2_look',
  107. path: 'holding2_look',
  108. meta: { myInd: 1 },
  109. component: () => import('@/views/holding/holding2_look.vue')
  110. },
  111. {
  112. name: 'holding3',
  113. path: 'holding3',
  114. meta: { myInd: 1, keepAlive: true },
  115. component: () => import('@/views/holding/holding3.vue')
  116. },
  117. {
  118. name: 'holding3_look',
  119. path: 'holding3_look',
  120. meta: { myInd: 1 },
  121. component: () => import('@/views/holding/holding3_look.vue')
  122. },
  123. {
  124. name: 'holding4',
  125. path: 'holding4',
  126. meta: { myInd: 1 },
  127. component: () => import('@/views/holding/holding4.vue')
  128. },
  129. {
  130. name: 'holding4_audit',
  131. path: 'holding4_audit',
  132. meta: { myInd: 1 },
  133. component: () => import('@/views/holding/holding4_audit.vue')
  134. },
  135. {
  136. name: 'holding4_look',
  137. path: 'holding4_look',
  138. meta: { myInd: 1 },
  139. component: () => import('@/views/holding/holding4_look.vue')
  140. },
  141. {
  142. name: 'holding5',
  143. path: 'holding5',
  144. meta: { myInd: 1 },
  145. component: () => import('@/views/holding/holding5.vue')
  146. },
  147. {
  148. name: 'holding5_add',
  149. path: 'holding5_add',
  150. meta: { myInd: 1 },
  151. component: () => import('@/views/holding/holding5_add.vue')
  152. },
  153. {
  154. name: 'holding5_audit',
  155. path: 'holding5_audit',
  156. meta: { myInd: 1 },
  157. component: () => import('@/views/holding/holding5_audit.vue')
  158. },
  159. {
  160. name: 'holding5_look',
  161. path: 'holding5_look',
  162. meta: { myInd: 1 },
  163. component: () => import('@/views/holding/holding5_look.vue')
  164. },
  165. {
  166. name: 'holding0_DiaEdit',
  167. path: 'holding0_DiaEdit',
  168. meta: { myInd: 1 },
  169. component: () => import('@/views/holding/holding0_DiaEdit.vue')
  170. },
  171. // 征集品管理
  172. {
  173. name: 'collect0',
  174. path: 'collect0',
  175. meta: { myInd: 2, keepAlive: true },
  176. component: () => import('@/views/collect/collect0.vue')
  177. },
  178. {
  179. name: 'collect0_look',
  180. path: 'collect0_look',
  181. meta: { myInd: 2 },
  182. component: () => import('@/views/collect/collect0_look.vue')
  183. },
  184. {
  185. name: 'collect1',
  186. path: 'collect1',
  187. meta: { myInd: 2 },
  188. component: () => import('@/views/collect/collect1.vue')
  189. },
  190. {
  191. name: 'collect1_add',
  192. path: 'collect1_add',
  193. meta: { myInd: 2 },
  194. component: () => import('@/views/collect/collect1_add.vue')
  195. },
  196. {
  197. name: 'collect1_audit',
  198. path: 'collect1_audit',
  199. meta: { myInd: 2 },
  200. component: () => import('@/views/collect/collect1_audit.vue')
  201. },
  202. {
  203. name: 'collect1_look',
  204. path: 'collect1_look',
  205. meta: { myInd: 2 },
  206. component: () => import('@/views/collect/collect1_look.vue')
  207. },
  208. {
  209. name: 'collect2',
  210. path: 'collect2',
  211. meta: { myInd: 2 },
  212. component: () => import('@/views/collect/collect2.vue')
  213. },
  214. {
  215. name: 'collect2_add',
  216. path: 'collect2_add',
  217. meta: { myInd: 2 },
  218. component: () => import('@/views/collect/collect2_add.vue')
  219. },
  220. {
  221. name: 'collect2_audit',
  222. path: 'collect2_audit',
  223. meta: { myInd: 2 },
  224. component: () => import('@/views/collect/collect2_audit.vue')
  225. },
  226. {
  227. name: 'collect2_look',
  228. path: 'collect2_look',
  229. meta: { myInd: 2 },
  230. component: () => import('@/views/collect/collect2_look.vue')
  231. },
  232. // 库房管理
  233. {
  234. name: 'statistics0',
  235. path: 'statistics0',
  236. meta: { myInd: 3 },
  237. component: () => import('@/views/statistics/statistics0.vue')
  238. },
  239. {
  240. name: 'statistics1',
  241. path: 'statistics1',
  242. meta: { myInd: 3 },
  243. component: () => import('@/views/statistics/statistics1.vue')
  244. },
  245. // 系统管理
  246. {
  247. name: 'system1',
  248. path: 'system1',
  249. meta: { myInd: 4 },
  250. component: () => import('@/views/system/system1.vue')
  251. },
  252. {
  253. name: 'system2',
  254. path: 'system2',
  255. meta: { myInd: 4 },
  256. component: () => import('@/views/system/system2.vue')
  257. }
  258. ]
  259. }
  260. ]
  261. })
  262. router.beforeEach((to, from, next) => {
  263. // 如果是去登录页,不需要验证,直接下一步
  264. if (to.name === 'login') next()
  265. // 否则要有token值才能下一步,不然就返回登录页
  266. else {
  267. const token = localStorage.getItem('daliCK_token')
  268. if (token) next()
  269. else {
  270. Message.warning('登录失效,请重新登录')
  271. next({ name: 'login' })
  272. }
  273. }
  274. })
  275. export default router