import store from './store' const routes = [ { name: 'home', path: '/:patchNum', component: () => import(/* webpackChunkName: 'home' */ '@/components/Home'), }, { name: 'report', path: '/:patchNum/report', component: () => import(/* webpackChunkName: 'report' */ '@/components/Report'), }, { name: 'buy', path: '/:patchNum/buy', component: () => import(/* webpackChunkName: 'buy' */ '@/components/Buy'), }, ] const router = new VueRouter({ mode: 'history', routes, }) router.beforeEach(async (to, from, next) => { if (!store.state.trace.patch_num) { await store.dispatch('getTrace', to.params.patchNum) } next() }) export default router