router.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. import { interopDefault } from './utils'
  4. const _017ba64e = () => interopDefault(import('../pages/index.vue' /* webpackChunkName: "pages/index" */))
  5. const _3599ba51 = () => interopDefault(import('../pages/index/index.vue' /* webpackChunkName: "pages/index/index" */))
  6. const _dfb55690 = () => interopDefault(import('../pages/index/cert/index.vue' /* webpackChunkName: "pages/index/cert/index" */))
  7. const _6952764e = () => interopDefault(import('../pages/index/type/index.vue' /* webpackChunkName: "pages/index/type/index" */))
  8. const _dcf8ade6 = () => interopDefault(import('../pages/index/cert/freelancer.vue' /* webpackChunkName: "pages/index/cert/freelancer" */))
  9. const _bc074ab6 = () => interopDefault(import('../pages/index/cert/id.vue' /* webpackChunkName: "pages/index/cert/id" */))
  10. const _ca5e67b8 = () => interopDefault(import('../pages/index/type/pay.vue' /* webpackChunkName: "pages/index/type/pay" */))
  11. const _3543bdce = () => interopDefault(import('../pages/index/type/vip.vue' /* webpackChunkName: "pages/index/type/vip" */))
  12. const _8c50bd16 = () => interopDefault(import('../pages/index/vip/pay.vue' /* webpackChunkName: "pages/index/vip/pay" */))
  13. Vue.use(Router)
  14. if (process.client) {
  15. window.history.scrollRestoration = 'manual'
  16. }
  17. const scrollBehavior = function (to, from, savedPosition) {
  18. // if the returned position is falsy or an empty object,
  19. // will retain current scroll position.
  20. let position = false
  21. // if no children detected
  22. if (to.matched.length < 2) {
  23. // scroll to the top of the page
  24. position = { x: 0, y: 0 }
  25. } else if (to.matched.some(r => r.components.default.options.scrollToTop)) {
  26. // if one of the children has scrollToTop option set to true
  27. position = { x: 0, y: 0 }
  28. }
  29. // savedPosition is only available for popstate navigations (back button)
  30. if (savedPosition) {
  31. position = savedPosition
  32. }
  33. return new Promise((resolve) => {
  34. // wait for the out transition to complete (if necessary)
  35. window.$nuxt.$once('triggerScroll', () => {
  36. // coords will be used if no selector is provided,
  37. // or if the selector didn't match any element.
  38. if (to.hash) {
  39. let hash = to.hash
  40. // CSS.escape() is not supported with IE and Edge.
  41. if (typeof window.CSS !== 'undefined' && typeof window.CSS.escape !== 'undefined') {
  42. hash = '#' + window.CSS.escape(hash.substr(1))
  43. }
  44. try {
  45. if (document.querySelector(hash)) {
  46. // scroll to anchor by returning the selector
  47. position = { selector: hash }
  48. }
  49. } catch (e) {
  50. console.warn('Failed to save scroll position. Please add CSS.escape() polyfill (https://github.com/mathiasbynens/CSS.escape).')
  51. }
  52. }
  53. resolve(position)
  54. })
  55. })
  56. }
  57. export function createRouter() {
  58. return new Router({
  59. mode: 'history',
  60. base: '/',
  61. linkActiveClass: 'nuxt-link-active',
  62. linkExactActiveClass: 'nuxt-link-exact-active',
  63. scrollBehavior,
  64. routes: [{
  65. path: "/",
  66. component: _017ba64e,
  67. children: [{
  68. path: "",
  69. component: _3599ba51,
  70. name: "index"
  71. }, {
  72. path: "cert",
  73. component: _dfb55690,
  74. name: "index-cert"
  75. }, {
  76. path: "type",
  77. component: _6952764e,
  78. name: "index-type"
  79. }, {
  80. path: "cert/freelancer",
  81. component: _dcf8ade6,
  82. name: "index-cert-freelancer"
  83. }, {
  84. path: "cert/id",
  85. component: _bc074ab6,
  86. name: "index-cert-id"
  87. }, {
  88. path: "type/pay",
  89. component: _ca5e67b8,
  90. name: "index-type-pay"
  91. }, {
  92. path: "type/vip",
  93. component: _3543bdce,
  94. name: "index-type-vip"
  95. }, {
  96. path: "vip/pay",
  97. component: _8c50bd16,
  98. name: "index-vip-pay"
  99. }]
  100. }],
  101. fallback: false
  102. })
  103. }