index.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. import Vue from 'vue'
  2. import VueRouter from 'vue-router'
  3. Vue.use(VueRouter)
  4. const routes = [
  5. {
  6. path: '/',
  7. name: 'Layout',
  8. component: () => import('../views/Layout/index.vue'),
  9. redirect: { name: 'Home' },
  10. children: [
  11. // 首页
  12. {
  13. path: '/Layout/Home',
  14. name: 'Home',
  15. component: () => import('../views/Home/index.vue'),
  16. meta: { myTitle: 'Capital Museum.China', topColor: '#74120b' },
  17. },
  18. // Visit页面
  19. {
  20. path: '/Layout/Visit/:id',
  21. name: 'Visit',
  22. component: () => import('../views/Visit/index.vue'),
  23. meta: { myTitle: 'Visit', topColor: '#c3ac8d' },
  24. },
  25. {
  26. path: '/Layout/VisitInfo',
  27. name: 'VisitInfo',
  28. component: () => import('../views/Visit/VisitInfo.vue'),
  29. meta: { myTitle: 'Reservation', topColor: '#c3ac8d' },
  30. },
  31. // Exhibitions页面
  32. {
  33. path: '/Layout/Exhibitions',
  34. name: 'Exhibitions',
  35. component: () => import('../views/Exhibitions/index.vue'),
  36. meta: { myTitle: 'Exhibitions', topColor: '#bf8a6d' },
  37. redirect: { name: 'ExCurrent' },
  38. children: [
  39. // 二级路由子页面
  40. {
  41. path: '/Layout/Exhibitions/Current',
  42. name: 'ExCurrent',
  43. component: () => import('../views/Exhibitions/Current.vue'),
  44. meta: { myTitle: 'Exhibitions', topColor: '#bf8a6d' },
  45. },
  46. {
  47. path: '/Layout/Exhibitions/Permanent',
  48. name: 'ExPermanent',
  49. component: () => import('../views/Exhibitions/Permanent.vue'),
  50. meta: { myTitle: 'Exhibitions', topColor: '#bf8a6d' },
  51. },
  52. {
  53. path: '/Layout/Exhibitions/Past',
  54. name: 'ExPast',
  55. component: () => import('../views/Exhibitions/Past.vue'),
  56. meta: { myTitle: 'Exhibitions', topColor: '#bf8a6d' },
  57. },
  58. {
  59. path: '/Layout/Exhibitions/Overseas',
  60. name: 'ExOverseas',
  61. component: () => import('../views/Exhibitions/Overseas.vue'),
  62. meta: { myTitle: 'Exhibitions', topColor: '#bf8a6d' },
  63. },
  64. ]
  65. },
  66. //---------- 详情
  67. {
  68. path: '/Layout/Detail',
  69. name: 'ExDetail',
  70. component: () => import('../views/Exhibitions/Detail.vue'),
  71. meta: { myTitle: 'Exhibitions', topColor: '#801c20' },
  72. },
  73. // ----------Objects
  74. {
  75. path: '/Layout/Objects',
  76. name: 'ExObjects',
  77. component: () => import('../views/Exhibitions/Objects.vue'),
  78. meta: { myTitle: 'Exhibitions', topColor: '#801c20' },
  79. },
  80. // ----------Galleries
  81. {
  82. path: '/Layout/Galleries',
  83. name: 'ExGalleries',
  84. component: () => import('../views/Exhibitions/Galleries.vue'),
  85. meta: { myTitle: 'Exhibitions', topColor: '#801c20' },
  86. },
  87. // Collections页面
  88. {
  89. path: '/Layout/Collections',
  90. name: 'Collections',
  91. component: () => import('../views/Collections/index.vue'),
  92. meta: { myTitle: 'Collections', topColor: '#b09c86' },
  93. },
  94. {
  95. path: '/Layout/Collections/:id',
  96. name: 'CollectionsInfo',
  97. component: () => import('../views/Collections/info.vue'),
  98. meta: { myTitle: 'Collections', topColor: '#36382f' },
  99. },
  100. {
  101. path: '/Layout/CollectionsDetail',
  102. name: 'CollectionsDetail',
  103. component: () => import('../views/Collections/Detail.vue'),
  104. meta: { myTitle: 'Collections', topColor: '#656567' },
  105. },
  106. // Learn页面
  107. {
  108. path: '/Layout/Learn',
  109. name: 'Learn',
  110. component: () => import('../views/Learn/index.vue'),
  111. meta: { myTitle: 'Learn & Engage', topColor: '#997369' },
  112. redirect: { name: 'LearnStudents' },
  113. children: [
  114. // 二级路由子页面
  115. {
  116. path: '/Layout/Learn/Students',
  117. name: 'LearnStudents',
  118. component: () => import('../views/Learn/Students.vue'),
  119. meta: { myTitle: 'Learn & Engage', topColor: '#997369' },
  120. },
  121. {
  122. path: '/Layout/Learn/Adults',
  123. name: 'LearnAdults',
  124. component: () => import('../views/Learn/Adults.vue'),
  125. meta: { myTitle: 'Learn & Engage', topColor: '#997369' },
  126. },
  127. {
  128. path: '/Layout/Learn/Families',
  129. name: 'LearnFamilies',
  130. component: () => import('../views/Learn/Families.vue'),
  131. meta: { myTitle: 'Learn & Engage', topColor: '#997369' },
  132. },
  133. ]
  134. },
  135. {
  136. path: '/Layout/Learn/Info',
  137. name: 'LearnInfo',
  138. component: () => import('../views/Learn/info.vue'),
  139. meta: { myTitle: 'Learn & Engage', topColor: '#764032' },
  140. },
  141. // Publications页面
  142. {
  143. path: '/Layout/Publications',
  144. name: 'Publications',
  145. component: () => import('../views/Publications/index.vue'),
  146. meta: { myTitle: 'Publications', topColor: '#cdb6ac' },
  147. redirect: { name: 'PuMagazines' },
  148. children: [
  149. // 二级路由子页面
  150. {
  151. path: '/Layout/Publications/Magazines',
  152. name: 'PuMagazines',
  153. component: () => import('../views/Publications/Magazines.vue'),
  154. meta: { myTitle: 'Publications', topColor: '#cdb6ac' },
  155. },
  156. {
  157. path: '/Layout/Publications/Catalogues',
  158. name: 'PuCatalogues',
  159. component: () => import('../views/Publications/Catalogues.vue'),
  160. meta: { myTitle: 'Publications', topColor: '#cdb6ac' },
  161. },
  162. ]
  163. },
  164. // -------------info
  165. {
  166. path: '/Layout/Publications/Info',
  167. name: 'PublicationsInfo',
  168. component: () => import('../views/Publications/info.vue'),
  169. meta: { myTitle: 'Publications', topColor: 'rgba(110,148,141,.9)' },
  170. },
  171. //pdf
  172. {
  173. path: '/Layout/Publications/Pdf',
  174. name: 'PublicationsPdf',
  175. component: () => import('../views/Publications/lookPdf.vue'),
  176. meta: { myTitle: 'Publications', topColor: '#74120b' },
  177. },
  178. // Join & Support页面
  179. {
  180. path: '/Layout/Join',
  181. name: 'Join',
  182. component: () => import('../views/Join/index.vue'),
  183. meta: { myTitle: 'Join & Support', topColor: '#b37f52' },
  184. redirect: { name: 'JoinVo' },
  185. children: [
  186. // 二级路由子页面
  187. {
  188. path: '/Layout/Join/Volunteer',
  189. name: 'JoinVo',
  190. component: () => import('../views/Join/Volunteer.vue'),
  191. meta: { myTitle: 'Join & Support', topColor: '#b37f52' },
  192. },
  193. {
  194. path: '/Layout/Join/Give',
  195. name: 'JoinGi',
  196. component: () => import('../views/Join/Give.vue'),
  197. meta: { myTitle: 'Join & Support', topColor: '#b37f52' },
  198. },
  199. ]
  200. },
  201. // -------------info
  202. {
  203. path: '/Layout/Join/Info',
  204. name: 'JoinInfo',
  205. component: () => import('../views/Join/info.vue'),
  206. meta: { myTitle: 'Join & Support', topColor: '#b37f52' },
  207. },
  208. ]
  209. }
  210. ]
  211. const router = new VueRouter({
  212. // mode: 'history',
  213. base: process.env.BASE_URL,
  214. routes
  215. })
  216. // 导航守卫,回到页面顶部
  217. router.beforeEach((to, from, next) => {
  218. setTimeout(() => {
  219. let dom = document.querySelector('.Layout')
  220. dom.scrollTop = 0
  221. }, 100);
  222. next()
  223. })
  224. // 全局后置钩子,设置title
  225. router.afterEach(to => {
  226. // 设置title
  227. document.title = to.meta.myTitle;
  228. })
  229. export default router