登录状态 登录状态

登录状态

import Vue from 'vue'
import Router from 'vue-router'
import Login from './components/login/index.vue'
import Index from './components/index/index.vue'
import Home from './views/Home.vue'
import ChangePass from './views/nav1/user.vue'
import Table from './views/nav1/Table.vue'
import Main from './views/index.vue'
import store from './store/index'
Vue.use(Router)

const router= new Router({
  routes: [
     {
      path: '/',
      name: '',
      meta:{
        title:"首页"
      },
      component: Main,
      hidden: true 
    },
    {
      path: '/login',
      name: 'login',
      meta:{
        title:"登录页面"
      },
      component: Login,
      hidden: true 
    },
    // {
    //   path:"/index",
    //   name:"index",
    //   meta:{
    //     title:"后台管理"
    //   },
    //   component:Index,
    //   hidden: true 
    //   },
      {
      path:"/index",
      name:"上传管理",
      meta:{
        title:"后台管理",
        auth:true
      },
      component:Home,
      iconCls: 'el-icon-upload',//图标样式class
        children: [
           { path: '/index', component:Index, name: '上传', meta:{title:"后台管理"}},
            { path: '/index/piclist', component:Table, name: '上传列表', meta:{title:"后台管理"}},
            
        ]
      },
      {
      path:"/pass",
      name:"密码管理",
      meta:{
        title:"后台管理",
        auth:true
      },
      component:Home,
      iconCls: 'el-icon-edit',//图标样式class
        children: [
          { path: '/pass', component:ChangePass, name: '修改密码', meta:{title:"后台管理"}}
            
        ]
      }
  ]
});
router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  if(to.matched.some(m=>m.meta.auth)){
      if(store.state.login.isLogin==1){
          next();
      }else{
        next({path:"/login",query:{rurl:to.fullPath}});
      }
    
  }else{
      next();
  }

})
export default router
分享本文至:

评论 0

挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
提交评论

清空信息
关闭评论