Kaynağa Gözat

解决方案SEO部分修改

xinfeng 5 yıl önce
ebeveyn
işleme
2c2ef56d22

+ 3 - 1
components/header.vue

@@ -46,7 +46,7 @@
           <el-dropdown-item>
             <a
               class="workstation"
-              :href="baseUrl+'/kaifain'"
+              :href="kaifainUrl"
               style="display: flex; align-items: center;"
             >
               <img
@@ -262,6 +262,7 @@ export default {
     return {
       baseUrl: "",
       jishuBaseUrl: "",
+      kaifainUrl: "",
       // 搜索的关键词
       keywork: "",
       // 消息数量
@@ -364,6 +365,7 @@ export default {
   created() {
     this.baseUrl = this.$store.state.domainConfig.siteUrl;
     this.jishuBaseUrl = this.$store.state.domainConfig.jishuinUrl;
+    this.kaifainUrl = this.$store.state.domainConfig.kaifainUrl;
   }
 };
 </script>

+ 4 - 1
components/kaifain/dealSeoFooter.js

@@ -1,9 +1,10 @@
 export default class DealSeoData {
-  constructor({ $axios, req, app, redirect }) {
+  constructor({ $axios, req, app, redirect, store }) {
     this.$axios = $axios
     this.req = req
     this.app = app
     this.redirect = redirect
+    this.store = store
     this.selected = {
       city: 0,
       industry: 0,
@@ -51,6 +52,8 @@ export default class DealSeoData {
     const typeList = this.typeList
     const { city, industry, techType, cityName = "", industryName = "", techTypeName = "", proviceName } = this.selected
     const { headers: { host } } = this.req
+    const kaifainUrl = this.store.state.domainConfig.kaifainUrl
+    
     let footer = {
       baseLink: "", link: [
         { name: "", data: [] }, { name: "", data: [] },

+ 12 - 0
middleware/SeoRouter/kaifain.js

@@ -0,0 +1,12 @@
+export default function (context) {
+  if (!process.server) {
+    return
+  }
+  const {kaifainUrl} = context.store.state.domainConfig
+  const { req:{headers:{host}} } = context;
+  
+  console.log("********", host, kaifainUrl)
+  if (kaifainUrl.indexOf(host) !== -1) {
+  
+  }
+}

+ 2 - 36
nuxt.config.js

@@ -151,45 +151,11 @@ module.exports = {
    ** Build configuration
    */
   build: {
-    /*
-     ** You can extend webpack config here
-     */
-    // extractCSS: {
-    //   //提取html中的 css到文件
-    //   splitChunks: {
-    //     cacheGroups: {
-    //       styles: {
-    //         name: "styles",
-    //         test: /\.(css|vue|scss|less)$/,
-    //         chunks: "all",
-    //         enforce: true
-    //       }
-    //     }
-    //   }
-    // },
-    // optimization: {
-    //   splitChunks: {
-    //     chunks: "all",
-    //     automaticNameDelimiter: ".",
-    //     name: undefined,
-    //     cacheGroups: {}
-    //   }
-    // },
-    // extend(config, ctx) {
-    //   config.optimization = {
-    //     splitChunks: {
-    //       chunks: "all",
-    //       automaticNameDelimiter: ".",
-    //       name: undefined,
-    //       cacheGroups: {}
-    //     }
-    //   };
-    //   //console.log(config);
-    // }
+  
   },
 
   router: {
-    middleware: "initialize",
+    middleware: ["initialize", 'SeoRouter/kaifain'],
     ...seoRouter
   }
 };

+ 1 - 1
pages/kaifain/add/index.vue

@@ -621,7 +621,7 @@
         window.open(item.file, '__black')
       },
       jumpToOther() {
-        let url = "https://www.proginn.com/kaifain/s/10"
+        let url = "https://kaifain.proginn.com/kaifain/s/10"
         window.open(url, '__black')
       }
     },

+ 2 - 2
pages/kaifain/index.vue

@@ -41,7 +41,7 @@
             <nuxt-link class="cell"
               v-for="item in dataList"
               :key="item.id"
-              :to="`/kaifain/s/${item.id}.html`"
+              :to="`/kaifain/s/${item.hash_id}`"
               target="_blank"
               :title="item.name"
             >
@@ -119,7 +119,7 @@
           <nuxt-link class="cell"
             v-for="item in dataList"
             :key="item.id"
-            :to="`/kaifain/s/${item.id}.html`"
+            :to="`/kaifain/s/${item.hash_id}`"
             target="_blank"
           >
             <div class="bodyCont">

+ 1 - 1
pages/kaifain/preview.vue

@@ -55,7 +55,7 @@
           <nuxt-link class="cell"
             v-for="item in detail.successful_case"
             :key="item.id"
-            :to="`/kaifain/case/${item.id}.html`"
+            :to="`/kaifain/case/${item.hash_id}`"
             target="_blank"
             :title="item.name"
           >

+ 1 - 1
pages/otherpage/kaifain/viewHistory.vue

@@ -167,7 +167,7 @@
       },
       jumpToKaifain(item) {
         const {provider: {id, hash_id} = {}} = item
-        location.href = `/kaifain/s/${id}.html`
+        location.href = `/kaifain/s/${hash_id}`
       }
     }
   }

+ 3 - 1
pages/user/_id/_type.vue

@@ -320,6 +320,7 @@
       return {
         baseUrl: "",
         jishuBaseUrl: "",
+        kaifainUrl: "",
         uid: '',
         list: [],
         currentPage: 1,
@@ -343,6 +344,7 @@
       this.getType()
       this.baseUrl = this.$store.state.domainConfig.siteUrl;
       this.jishuBaseUrl = this.$store.state.domainConfig.jishuinUrl;
+      this.kaifainUrl = this.$store.state.domainConfig.kaifainUrl;
     },
     mounted() {
       container = this.$refs.container;
@@ -428,7 +430,7 @@
         if (this.mobile) {
           Toast("请前往程序员客栈,添加解决方案")
         } else {
-          window.open(this.baseUrl + '/kaifain/add')
+          window.open(this.kaifainUrl + '/kaifain/add')
         }
       },
       async addVideo() {

+ 0 - 3
plugins/nuxtAxios.js

@@ -44,9 +44,6 @@ export default function ({
 
   $axios.onResponse(res => {
     const data = res.data;
-    console.log("res:::::::::");
-    console.log(res.config.url);
-    console.log(JSON.stringify(data));
     let needLogin = false;
     if (res.config && res.config.data && typeof res.config.data === "string") {
       const queryData = res.config.data;