1234567891011121314151617181920212223242526272829303132333435 |
- 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
|