Acathur 5 лет назад
Родитель
Сommit
d1d24f954f
4 измененных файлов с 19 добавлено и 14 удалено
  1. 6 0
      middleware/initialize.js
  2. 2 1
      pages/kaifain/case/_tid.vue
  3. 10 7
      pages/kaifain/detail/_tid/index.vue
  4. 1 6
      store/index.ts

+ 6 - 0
middleware/initialize.js

@@ -177,6 +177,12 @@ export default function (context) {
   context.store.commit("updateDeviceType", context.app.$deviceType || {});
   context.store.commit("updateIsPC", context.app.$deviceType.pc || false);
   context.store.commit("updateIsWeixin", context.app.$deviceType.wx || false);
+
+  const host = process.server ? context.req.headers.host : location.host
+  const matchedScope = host && /(kaifain|jishuin|job)/.exec(host)
+
+  matchedScope && context.store.commit('scope:set', matchedScope[1])
+
   // 301
   // Server-side
   if (process.server) {

+ 2 - 1
pages/kaifain/case/_tid.vue

@@ -51,8 +51,9 @@
     layout: "opacity_header",
     components: {ConnectUs, KaifainFooter, Topnav},
     head() {
+      const { title = '' } = this.detail || {}
       return {
-        title: this.detail.title + "-开发屋",
+        title: (title ? `${title}-` : '') + '开发屋',
         meta: [ {
           'name': 'keywords',
           'content': '定制化Saas、PasS、API、行业技术解决方案'

+ 10 - 7
pages/kaifain/detail/_tid/index.vue

@@ -141,24 +141,26 @@ export default {
   layout: "opacity_header",
   components: { ConnectUs, KaifainFooter, ChangeBgImage, Topnav },
   head() {
-    let title = `${this.detail.title}介绍,功能,开发解决方案-开发屋`;
+    const { title = '' } = this.detail || {}
+    let docTitle = title ? `${title}介绍,功能,开发解决方案-开发屋` : '开发屋-开发解决方案'
+
     if (this.$deviceType.app) {
-      title = this.detail.title;
+      docTitle = title
     }
     return {
-      title: title,
+      title: docTitle,
       meta: [
         {
           name: "keywords",
-          content: `${this.detail.title}`,
+          content: title,
         },
         {
           name: "descrption",
-          content: `${this.detail.title}详细介绍,包括不限于功能、接口、企业开发着对接和布局${this.detail.title}的方法和详细的开发文档说明。`,
+          content: `${title}详细介绍,包括不限于功能、接口、企业开发着对接和布局${title}的方法和详细的开发文档说明。`,
         },
         {
           name: "h1",
-          content: `${this.detail.title}`,
+          content: `${title}`,
         },
       ],
     };
@@ -247,7 +249,8 @@ export default {
       jishuinUrl: "",
       kaifainUrl: "",
       siteUrl: "",
-      topnavFixed: false
+      topnavFixed: false,
+      mobile: false
     };
   },
   created() {

+ 1 - 6
store/index.ts

@@ -69,14 +69,9 @@ export const actions = {
   async nuxtServerInit({
     commit
   }, {
-    app,
-    req
+    app
   }) {
-    const { host, referer } = req.headers
-    const matchedScope = host && /(kaifain|jishuin|job)/.exec(host || referer && new URL(referer).hostname || '')
-
     commit("updateDeviceType", app.$deviceType || {});
-    matchedScope && commit('scope:set', matchedScope[1])
   }
 };