king
2021-01-19 c57f6da46e2a52f7d5fb39d348d75134e57b0aca
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',//解决方案 详情
        path: '/csd/:menuId',//解决方案 详情
        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',//解决方案
        path: '/sol.html',//解决方案
        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)
})