index.js 3.47 KB
import Vue from 'vue'
import Router from 'vue-router'

import Login from './../pages/Login.vue'
import NotFound from './../pages/404.vue'
import Home from './../pages/Home.vue'
import Main from './../pages/Main.vue'
import Table from './../pages/nav1/Table.vue'
import Form from './../pages/nav1/Form.vue'
import user from './../pages/nav1/user.vue'
// import Page4 from './../pages/nav2/Page4.vue'
// import Page5 from './../pages/nav2/Page5.vue'
// import Page6 from './../pages/nav3/Page6.vue'
// import Echart from './../pages/nav3/Page6.vue'
import echarts from './../pages/charts/echarts.vue'
import Apps from './../pages/apps/Apps.vue'
import Report from './../pages/report/Report.vue'
import CheckCode from './../pages/checkcode/CheckCode.vue'
import LotteryQuery from './../pages/lottery/index.vue'

import {
  COOKIES_EX
} from "./../global/const-data";

Vue.use(Router)

const router = new Router({
  routes: [{
      path: '/login',
      component: Login,
      name: '',
      hidden: true
    },
    {
      path: '/404',
      component: NotFound,
      name: '',
      hidden: true
    },

    {
      path: '/',
      component: Home,
      name: '',
      iconCls: 'fa fa-address-card',
      leaf: true, //只有一个节点
      children: [{
        path: '/apps',
        component: Apps,
        name: '应用中心'
      }]
    },
    {
      path: '/',
      component: Home,
      name: '',
      iconCls: 'fa fa-address-card',
      leaf: true, //只有一个节点
      hidden: true,
      children: [{
        path: '/report',
        component: Report,
        name: '报表'
      }]
    },
    {
      path: '/',
      component: Home,
      name: '',
      iconCls: 'fa fa-address-card',
      leaf: true, //只有一个节点
      hidden: true,
      children: [{
        path: '/checkcode',
        component: CheckCode,
        name: '查码'
      }]
    },
    {
      path: '/',
      component: Home,
      name: '',
      iconCls: 'fa fa-address-card',
      leaf: true, //只有一个节点
      children: [{
        path: '/lottery/query',
        component: LotteryQuery,
        name: '抽奖查询'
      }]
    },
    //{ path: '/main', component: Main },
    // {
    //   path: '/',
    //   component: Home,
    //   name: '导航一',
    //   hidden: true,
    //   iconCls: 'el-icon-message', //图标样式class
    //   children: [{
    //       path: '/main',
    //       component: Main,
    //       name: '主页',
    //       hidden: true
    //     },
    //     {
    //       path: '/table',
    //       component: Table,
    //       name: 'Table'
    //     },
    //     {
    //       path: '/form',
    //       component: Form,
    //       name: 'Form'
    //     },
    //     {
    //       path: '/user',
    //       component: user,
    //       name: '列表'
    //     },
    //   ]
    // },
    {
      path: '/',
      component: Home,
      name: 'Charts',
      iconCls: 'fa fa-bar-chart',
      hidden: true,
      children: [{
        path: '/echarts',
        component: echarts,
        name: 'echarts'
      }]
    },
    {
      path: '*',
      hidden: true,
      redirect: {
        path: '/404'
      }
    }
  ]
})


router.beforeEach((to, from, next) => {
  //NProgress.start();
  if (to.path == '/login') {
    sessionStorage.removeItem(COOKIES_EX + 'sid');
  }
  let user = sessionStorage.getItem(COOKIES_EX + 'sid');
  if (!user && to.path != '/login') {
    next({
      path: '/login'
    })
  } else {
    next()
  }
})

export default router;