export default ({ app, context, req, store}) => { if (process.client) { const { host } = location || {} const isJob = host.indexOf('job') !== -1 if (isJob) { window.__NUXT__.routePath = app.context.route.path.replace(/^\/job/, '/') let jobIndex = app.router.options.routes.filter(v => v.name === 'job')[ 0 ] let jobDetail = app.router.options.routes.filter(v => v.name === 'job-detail-id')[ 0 ] let companyList = app.router.options.routes.filter(v => v.name === 'job-company-list-city')[ 0 ] let companyList2 = app.router.options.routes.filter(v => v.name === 'job-company-city')[ 0 ] let jobIndexNow = { name: jobIndex.name, path: '/*', component: jobIndex.component } let jobDetailNow = { name: jobDetail.name, path: '/d/:id?', component: jobDetail.component } let companyListNow = { name: companyList.name, path: '/company/list/:city?', component: companyList.component } // let companyListNow2 = { // name: companyList2.name, // path: '/company/:city?', // component: companyList2.component // } let jobOrderList = [ jobDetailNow, companyListNow, jobIndexNow ] try { app.router.options.routes.unshift(...jobOrderList) app.router.matcher.addRoutes(jobOrderList) } catch ( e ) { console.log(e) } } // console.log('router', app.router) app.router.beforeEach((to, from, next) => { console.log("beforeEach", to, from) next() }) } }