router.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. import Vue from 'vue';
  2. import Router from 'vue-router';
  3. Vue.use(Router);
  4. const routes = [
  5. {
  6. path: '*',
  7. redirect: '/login',
  8. navShow: false,
  9. content: "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
  10. },
  11. {
  12. name: 'login',
  13. component: () => import('./views/login'),
  14. meta: {
  15. title: '登录',
  16. navShow: false,
  17. content: "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
  18. }
  19. },
  20. {
  21. name: 'warning',
  22. component: () => import('./views/noUserWarning'),
  23. meta: {
  24. title: '未注册',
  25. navShow: false,
  26. content: "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
  27. }
  28. },
  29. {
  30. name: 'verify',
  31. component: () => import('./views/SecurityVerify'),
  32. meta: {
  33. title: '安全验证',
  34. navShow: false,
  35. content: "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
  36. }
  37. },
  38. {
  39. name: 'presentRegister',
  40. component: () => import('./views/PresentRegister'),
  41. meta: {
  42. title: '礼物登记',
  43. navShow: false,
  44. content: "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
  45. }
  46. },
  47. {
  48. name: 'index',
  49. component: () => import('./views/index'),
  50. meta: {
  51. title: '首页',
  52. navShow: true,
  53. content: "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
  54. }
  55. },
  56. {
  57. name: 'me',
  58. component: () => import('./views/me'),
  59. meta: {
  60. title: '我的',
  61. navShow: true,
  62. content: "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
  63. }
  64. },
  65. {
  66. name: 'share',
  67. component: () => import('./views/share'),
  68. meta: {
  69. title: '分享海报',
  70. navShow: false,
  71. content: "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
  72. }
  73. },
  74. {
  75. name: 'giftDetail',
  76. component: () => import('./views/giftDetail'),
  77. meta: {
  78. title: '礼品卡',
  79. navShow: false,
  80. content: "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
  81. }
  82. },
  83. {
  84. name:'assess',
  85. component: ()=>import('./views/Assess'),
  86. meta:{
  87. title:'礼物卡(评价)',
  88. navShow: false,
  89. content: "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
  90. }
  91. },
  92. {
  93. name:'betest',
  94. component: ()=>import('./views/beTest'),
  95. meta:{
  96. title:'内部测试',
  97. navShow: false,
  98. content: "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
  99. }
  100. }
  101. ];
  102. // add route path
  103. routes.forEach(route => {
  104. route.path = route.path || '/' + (route.name || '');
  105. });
  106. const router = new Router({ routes });
  107. router.beforeEach((to, from, next) => {
  108. if (to.meta.content) {
  109. document.getElementsByName('viewport')[0].content = to.meta.content;
  110. }
  111. const title = to.meta && to.meta.title;
  112. if (title) {
  113. document.title = title;
  114. }
  115. next();
  116. });
  117. export {
  118. router
  119. };