From c57f6da46e2a52f7d5fb39d348d75134e57b0aca Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 19 一月 2021 10:21:00 +0800
Subject: [PATCH] 2021-01-19

---
 src/router/index.js |   58 +++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 43 insertions(+), 15 deletions(-)

diff --git a/src/router/index.js b/src/router/index.js
index 5e99346..814105b 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -1,5 +1,6 @@
 import Vue from 'vue'
 import Router from 'vue-router'
+import Meta from './meta.json'
 
 Vue.use(Router)
 
@@ -42,32 +43,29 @@
   mode: 'history',
   routes: [{
     path: '/',
-    redirect: '/home.html'
-  }, {
-    path: '/',
     component: Home,
     children: [
       {
-        path: '/home.html',
+        path: '/',
         name: 'home',
         component: Index
       },
       {
-        path: '/productCenter/:menuId',//浜у搧杞欢
+        path: '/pdc/:menuId',//浜у搧杞欢
         name: 'productcenter',
         component: ProductCenter
       },
       {
-        path: '/successCase.html',//鎴愬姛妗堜緥
+        path: '/case.html',//鎴愬姛妗堜緥
         name: 'successcase',
         component: SuccessCase,
       },{
-        path: '/SuccessCaseIndex/:menuId',//鎴愬姛妗堜緥 璇︽儏
+        path: '/sci/:menuId',//鎴愬姛妗堜緥 璇︽儏
         name: 'successcaseindex',
         component: SuccessCaseIndex,
       },
       {
-        path: '/caseDetail/:menuId',//瑙e喅鏂规 璇︽儏
+        path: '/csd/:menuId',//瑙e喅鏂规 璇︽儏
         name: 'casedetail',
         component: CaseDetail
       },
@@ -82,27 +80,27 @@
         component: News
       },
       {
-        path: '/AboutMingKe.html',//鍏充簬鏄庣
+        path: '/amk.html',//鍏充簬鏄庣
         name: 'aboutmingKe',
         component: AboutMingKe
       },
       {
-        path: '/postDetails.html',//鑱屼綅璇︽儏
+        path: '/postd.html',//鑱屼綅璇︽儏
         name: 'postdetails',
         component: postDetails
       },
       {
-        path: '/companyProfile.html',//浼佷笟鏂囧寲
+        path: '/comp.html',//浼佷笟鏂囧寲
         name: 'company',
         component: CompanyProfile
       },
       {
-        path: '/companyProfile/:hash',//浼佷笟鏂囧寲
+        path: '/cpro/:hash',//浼佷笟鏂囧寲
         name: 'companyprofile',
         component: CompanyProfile
       },
       {
-        path: '/joinMingKe.html',//鍔犲叆鏄庣
+        path: '/joinmk.html',//鍔犲叆鏄庣
         name: 'joinmingke',
         component: JoinMingKe
       },
@@ -112,12 +110,12 @@
         component: ContactInformation
       },
       {
-        path: '/dynamicDetail/:menuId',//鏄庣鍔ㄦ�� 璇︽儏
+        path: '/dyd/:menuId',//鏄庣鍔ㄦ�� 璇︽儏
         name: 'dynamicdetail',
         component: DynamicDetail
       },
       {
-        path: '/caseSolution.html',//瑙e喅鏂规
+        path: '/sol.html',//瑙e喅鏂规
         name: 'casesolution',
         component: CaseSolution
       },
@@ -155,6 +153,36 @@
   }]
 })
 
+router.beforeEach((to, from, next) => {
+  let view = Meta.filter(item => {
+    if (to.params.menuId && item.menuId) {
+      return item.name === to.name && to.params.menuId.indexOf(item.menuId) > -1
+    } else {
+      return item.name === to.name
+    }
+  })[0]
+  
+  if (view) {
+    document.title = view.title
+    if (view.keywords) {
+      try {
+        let metas = document.getElementsByTagName('meta')
+        for (let i = 0; i < metas.length; i++) {
+          if (metas[i].name === 'keywords') {
+            metas[i].content = view.keywords
+          } else if (metas[i].name === 'description') {
+            metas[i].content = view.description
+          }
+        }
+      } catch (e) {
+        console.warn('meta 璁剧疆閿欒锛�')
+      }
+    }
+  }
+
+  next()
+})
+
 router.afterEach(() => {
   window.scrollTo(0, 0)
 })

--
Gitblit v1.8.0