index.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import Report from "./../pages/report.vue"
  2. import Login from "./../pages/login.vue"
  3. import AccountsReceivable from "./../pages/accountsReceivable.vue"
  4. import Results from "./../pages/results.vue"
  5. import NewReport from "./../pages/newReport.vue"
  6. import Stock from "./../pages/stock.vue"
  7. import Index from "../pages/index.vue"
  8. import { getParameterByName } from "../utils/auth"
  9. const routes = [
  10. { path:"/", component: Index },
  11. { path: '/report', component: Report},
  12. { path:'/login', component: Login},
  13. { path:'/newReport', component: NewReport},
  14. { path:'/results', component: Results},
  15. { path:'/accountsReceivable', component: AccountsReceivable},
  16. { path:'/stock', component: Stock},
  17. ]
  18. const router = new VueRouter({routes ,mode:'hash'})
  19. router.beforeEach((to, _, next) => {
  20. const path = getParameterByName('path')
  21. if(to.path === "/" && !path){
  22. next()
  23. }else if (to.path !== '/login' && !getParameterByName('code')) {
  24. next({
  25. path:'login',
  26. query:{ path }
  27. })
  28. } else {
  29. next()
  30. }
  31. })
  32. export default router