瀏覽代碼

SEO优化

xinfeng 5 年之前
父節點
當前提交
dc7b57c9d2
共有 1 個文件被更改,包括 5 次插入5 次删除
  1. 5 5
      plugins/router.js

+ 5 - 5
plugins/router.js

@@ -1,14 +1,11 @@
-export default ({ app, context, store }) => {
+export default ({ app, context,req, store }) => {
   
   if (process.server) {
-    const { req, } = context;
     let host = req.headers.host;
     const isKaifain = host.indexOf('kaifain') !== -1
     const isJishuin = host.indexOf('jishuin') !== -1
     const isJob = host.indexOf('job') !== -1
-    if (isKaifain) {
-      app.context.route.path = '/'
-    }
+    console.log("222222", app.context.route.path)
     return
   }
   
@@ -20,6 +17,7 @@ export default ({ app, context, store }) => {
     
     console.log("app.router.options.routes", app.router.options.routes)
     if (isKaifain) {
+      window.__NUXT__.routePath = app.context.route.path + '/kaifain'
       let kaifainIndex = app.router.options.routes.filter(v => v.name === 'kaifain')[ 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 ]
@@ -49,6 +47,7 @@ export default ({ app, context, store }) => {
     }
     
     if (isJishuin) {
+      window.__NUXT__.routePath = app.context.route.path + '/jishuin'
       let jishuinCIndex = app.router.options.routes.filter(v => v.name === "jishuinCollectedC1")[ 0 ]
       let jishuinCType = app.router.options.routes.filter(v => v.name === "jishuinCollectedCID1")[ 0 ]
       let jishuinUIndex = app.router.options.routes.filter(v => v.name === "jishuinUserU1")[ 0 ]
@@ -85,6 +84,7 @@ export default ({ app, context, store }) => {
     }
     
     if (isJob) {
+      window.__NUXT__.routePath = app.context.route.path + '/job'
       let jobIndex = app.router.options.routes.filter(v => v.name === 'JobListSeoIndex')[ 0 ]
       let jobDetail = app.router.options.routes.filter(v => v.name === 'job-detail-id')[ 0 ]
       let jobIndexNow = {