export default ({ app, context, req, store}) => { if (process.client) { const { host } = location || {} const isKaifain = host.indexOf('kaifain') !== -1 const isJishuin = host.indexOf('jishuin') !== -1 const isJob = host.indexOf('job') !== -1 // console.log('before Route Path', window.__NUXT__.routePath) // console.log("app.router.options.routes", app.router.options.routes) /* if (isKaifain) { window.__NUXT__.routePath = app.context.route.path.replace(/^\/kaifain/, '/') let kaifainIndex = app.router.options.routes.filter(v => v.name === 'kaifain')[0] let kaifainSearch = app.router.options.routes.filter(v => v.name === 'kaifainSearch')[0] let kaifainDetail = app.router.options.routes.filter(v => v.name === 'kaifain-detail-tid')[ 0 ] let kaifainCaseDetail = app.router.options.routes.filter(v => v.name === 'kaifain-case-tid')[ 0 ] let kaifainAdd = app.router.options.routes.filter(v => v.name === 'kaifain-add')[ 0 ] let kaifainPreview = app.router.options.routes.filter(v => v.name === 'kaifain-preview')[ 0 ] let kaifainPreviewCase = app.router.options.routes.filter(v => v.name === 'kaifain-previewCase')[ 0 ] let kaifainIndexNow = { name: 'kaifain_$', path: '/*', component: kaifainIndex.component } let kaifainDetailNow = { name: 'kaifainSeoDetails_$', path: '/s/:tid', component: kaifainDetail.component } let kaifainCaseDetailNow = { name: 'kaifainCaseSeoDetails_$', path: '/d/:tid', component: kaifainCaseDetail.component } let kaifainAddNow = { name: 'kaifainAdd_$', path: '/add', component: kaifainAdd.component } let kaifainPreviewNow = { name: 'kaifainPreview_$', path: '/preview', component: kaifainPreview.component } let kaifainPreviewCaseNow = { name: 'kaifainPreviewCase_$', path: '/previewCase', component: kaifainPreviewCase.component } let kaifainOrderList = [ kaifainPreviewCaseNow, kaifainPreviewNow, kaifainAddNow, kaifainCaseDetailNow, kaifainDetailNow, kaifainIndexNow ] try { app.router.options.routes.unshift(...kaifainOrderList) app.router.matcher.addRoutes(kaifainOrderList) } catch ( e ) { console.log(e) } } */ /* if (isJishuin) { window.__NUXT__.routePath = app.context.route.path.replace(/^\/jishuin/, '/') let jishuinCIndex = app.router.options.routes.filter(v => v.name === "user-collect_article-id-type")[ 0 ] let jishuinCType = app.router.options.routes.filter(v => v.name === "user-collect_article-id-type")[ 0 ] let jishuinUIndex = app.router.options.routes.filter(v => v.name === "user-id-type")[ 0 ] let jishuinUType = app.router.options.routes.filter(v => v.name === "user-id-type")[ 0 ] let jishuinU = { name: 'jishuinSeoU_$', path: '/u/:id', component: jishuinUIndex.component } let jishuinUT = { name: 'jishuinSeoUType_$', path: '/u/:id/:type', component: jishuinUType.component } let jishuinC = { name: 'jishuinSeoC_$', path: '/c/:id', component: jishuinCIndex.component } let jishuinCT = { name: 'jishuinSeoCT_$', path: '/c/:id/:type', component: jishuinCType.component } let jishuinOrderList = [ jishuinCT, jishuinC, jishuinUT, jishuinU ] try { app.router.options.routes.unshift(...jishuinOrderList) app.router.matcher.addRoutes(jishuinOrderList) } catch ( e ) { console.log(e) } } */ 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 jobIndexNow = { name: jobIndex.name, path: '/*', component: jobIndex.component } let jobDetailNow = { name: jobDetail.name, path: '/d/:id?', component: jobDetail.component } let jobOrderList = [ jobDetailNow, 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() }) } }