index.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { route } from 'quasar/wrappers';
  2. import {
  3. createMemoryHistory,
  4. createRouter,
  5. createWebHashHistory,
  6. createWebHistory,
  7. } from 'vue-router';
  8. import { StateInterface } from '../store';
  9. import routes from './routes';
  10. // import { nextTick } from 'vue'
  11. /*
  12. * If not building with SSR mode, you can
  13. * directly export the Router instantiation;
  14. *
  15. * The function below can be async too; either use
  16. * async/await or return a Promise which resolves
  17. * with the Router instance.
  18. */
  19. export default route<StateInterface>(function (/* { store, ssrContext } */) {
  20. const createHistory = process.env.SERVER
  21. ? createMemoryHistory
  22. : process.env.VUE_ROUTER_MODE === 'history'
  23. ? createWebHistory
  24. : createWebHashHistory;
  25. const Router = createRouter({
  26. // scrollBehavior (to, from, savedPosition) {
  27. // return { x: 0, y: 0 }
  28. // },
  29. // scrollBehavior: (to) => {
  30. // const idToScrollTo = to.hash
  31. // if (idToScrollTo && document.querySelector(idToScrollTo)) {
  32. // const el = document.querySelector(idToScrollTo)
  33. // if (el) el.scrollIntoView()
  34. // }
  35. // // void nextTick(()=>{
  36. // // if (idToScrollTo && document.querySelector(idToScrollTo)) {
  37. // // const el = document.querySelector(idToScrollTo)
  38. // // if (el) el.scrollIntoView()
  39. // // }
  40. // // })
  41. // return { left: 0, top: 0 }
  42. // },
  43. routes,
  44. // Leave this as is and make changes in quasar.conf.js instead!
  45. // quasar.conf.js -> build -> vueRouterMode
  46. // quasar.conf.js -> build -> publicPath
  47. history: createHistory(
  48. process.env.MODE === 'ssr' ? void 0 : process.env.VUE_ROUTER_BASE
  49. ),
  50. });
  51. return Router;
  52. });