diff --git a/webintroduce/src/components/VHeader.vue b/webintroduce/src/components/VHeader.vue index 1c580f0..d9bf4e6 100644 --- a/webintroduce/src/components/VHeader.vue +++ b/webintroduce/src/components/VHeader.vue @@ -20,7 +20,8 @@ export default { navLinks: [ {name:'首页',linkPath:'/home'}, {name:'解决方案',linkPath:'/solution'}, - {name:'登录',linkPath:'/login'} + {name:'登录',linkPath:'/login'}, + {name:'企业介绍',linkPath:'/enterprise'} ] } }, diff --git a/webintroduce/src/main.js b/webintroduce/src/main.js index 72d461b..ce47a79 100644 --- a/webintroduce/src/main.js +++ b/webintroduce/src/main.js @@ -3,14 +3,33 @@ import Vue from 'vue' import App from './App' import router from './router' - +import Cookies from 'js-cookie' require ('./assets/css/reset.css') Vue.config.productionTip = false router.beforeEach((to, from, next) =>{ - console.log(to) - document.title = to.meta.title - next() + + if(to.matched.some(record => record.meta.requiresAuth)){ + if(Cookies.get('username')){ + document.title = to.meta.title + next() + }else{ + next({ + path:'/login', + query: { redirect: to.fullPath } + }) + document.title = '登录' + } + + + }else { + document.title = to.meta.title + next() + } + + // console.log(to) + // + // next() }) /* eslint-disable no-new */ diff --git a/webintroduce/src/router/index.js b/webintroduce/src/router/index.js index acad057..a161625 100644 --- a/webintroduce/src/router/index.js +++ b/webintroduce/src/router/index.js @@ -19,7 +19,8 @@ export default new Router({ name: 'home', component: home, meta: { - title: '首页' + title: '首页', + requiresAuth: false } }, { @@ -27,23 +28,37 @@ export default new Router({ name: 'solution', component: solution, meta: { - title: '解决方案' + title: '解决方案', + requiresAuth: false } }, { - path: '/enterprise/:id', + path: '/enterprise', name: 'enterprise', component: enterprise, meta: { - title: '企业' - } + title: '企业', + requiresAuth: true + }, + child:[ + { + path: '/enterprise/:id', + name: 'enterprise', + component: enterprise, + meta: { + title: '企业', + requiresAuth: true + }, + } + ] }, { path: '/login', name: 'login', component: login, meta: { - title: '登录' + title: '登录', + requiresAuth: false } } ] diff --git a/webintroduce/src/views/login.vue b/webintroduce/src/views/login.vue index 92bd752..f81d5b7 100644 --- a/webintroduce/src/views/login.vue +++ b/webintroduce/src/views/login.vue @@ -1,10 +1,30 @@ - 登录页面没有公共的头部底部 + 登录页面没有公共的头部底部 + {{username}} + + +