index.js 5.58 KB
Newer Older
Pan's avatar
Pan committed
1 2
import Vue from 'vue'
import Router from 'vue-router'
Pan's avatar
Pan committed
3

Pan's avatar
Pan committed
4
Vue.use(Router)
Pan's avatar
Pan committed
5

Pan's avatar
Pan committed
6
/* Layout */
花裤衩's avatar
花裤衩 committed
7
import Layout from '@/layout'
Pan's avatar
Pan committed
8

9
/**
花裤衩's avatar
花裤衩 committed
10 11 12 13 14 15 16 17 18 19 20 21
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
22
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
花裤衩's avatar
花裤衩 committed
23 24
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
Pan's avatar
Pan committed
25
  }
花裤衩's avatar
花裤衩 committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
Pan's avatar
Pan committed
45

Pan's avatar
Pan committed
46 47 48 49
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
Pan's avatar
Pan committed
50 51
    children: [{
      path: 'dashboard',
花裤衩's avatar
花裤衩 committed
52 53
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
yanzhongrong's avatar
yanzhongrong committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
      meta: { title: '首页', icon: 'dashboard' }
    }]
  },
  {
    path: '/alarm',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'alarm',
      name: 'Alarm',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '告警管理', icon: 'dashboard' }
    }]
  },
  {
    path: '/setting',
    component: Layout,
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
    redirect: '/setting/add',
    name: 'Setting',
    meta: { title: '配置管理', icon: 'example' },
    children: [
      {
        path: 'add',
        name: 'settingAdd',
        component: () => import('@/views/setting/add/index'),
        meta: { title: '手动添加配置', icon: 'table' }
      },
      {
        path: 'statistics',
        name: 'settingAtatistics',
        component: () => import('@/views/setting/statistics/index'),
        meta: { title: '配置信息统计', icon: 'tree' }
      }
    ]
yanzhongrong's avatar
yanzhongrong committed
88 89 90 91 92
  },
  {
    path: '/monitor',
    component: Layout,
    redirect: '/dashboard',
许倩倩's avatar
许倩倩 committed
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
    name: '监测实时状态',
    meta: { title: '监测实时状态', icon: 'dashboard' },
    children: [
      {
        path: 'leakageCable',
        name: '漏缆实时状态',
        component: () => import('@/views/monitor/leakageCable'),
        meta: { title: '漏缆实时状态' }
      },
      {
        path: 'equipment',
        name: '设备实时状态',
        component: () => import('@/views/monitor/equipment'),
        meta: { title: '设备实时状态' }
      }
    ]
yanzhongrong's avatar
yanzhongrong committed
109 110 111 112
  },
  {
    path: '/maintain',
    component: Layout,
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
    redirect: '/maintain/oneself',
    name: 'Maintain',
    meta: { title: '维护管理', icon: 'example' },
    children: [
      {
        path: 'oneself',
        name: 'MaintainOneself',
        component: () => import('@/views/maintain/oneself/index'),
        meta: { title: '设备本身维护', icon: 'table' }
      },
      {
        path: 'parameter',
        name: 'MaintainParameter',
        component: () => import('@/views/maintain/parameter/index'),
        meta: { title: '设备告警参数设置', icon: 'tree' }
      }
    ]
yanzhongrong's avatar
yanzhongrong committed
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
  },
  {
    path: '/history',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'history',
      name: 'History',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '历史数据', icon: 'dashboard' }
    }]
  },
  {
    path: '/user',
    component: Layout,
renhanxue's avatar
renhanxue committed
145
    redirect: '/dashboard',
renhanxue's avatar
renhanxue committed
146 147
    name: 'User',
    meta: { title: '用户管理', icon: 'dashboard' },
yanzhongrong's avatar
yanzhongrong committed
148
    children: [{
renhanxue's avatar
renhanxue committed
149 150 151 152 153 154 155 156 157 158 159 160
      path: 'updateUser',
      name: 'UpdateUser',
      component: () => import('@/views/user/updateUser'),
      meta: { title: '个人信息管理', icon: 'dashboard' }
    },
    {
      path: 'userList',
      name: 'UserList',
      component: () => import('@/views/user/userList'),
      meta: { title: '用户信息列表', icon: 'dashboard' }
    }
    ]
161
  },
Pan's avatar
Pan committed
162 163 164 165

  {
    path: '/example',
    component: Layout,
Pan's avatar
Pan committed
166
    redirect: '/example/table',
Pan's avatar
Pan committed
167
    name: 'Example',
yanzhongrong's avatar
yanzhongrong committed
168
    meta: { title: 'Example', icon: 'example' },
Pan's avatar
Pan committed
169
    children: [
Pan's avatar
Pan committed
170
      {
Pan's avatar
Pan committed
171 172
        path: 'table',
        name: 'Table',
Pan's avatar
Pan committed
173
        component: () => import('@/views/table/index'),
Pan's avatar
Pan committed
174 175 176 177 178
        meta: { title: 'Table', icon: 'table' }
      },
      {
        path: 'tree',
        name: 'Tree',
Pan's avatar
Pan committed
179
        component: () => import('@/views/tree/index'),
Pan's avatar
Pan committed
180
        meta: { title: 'Tree', icon: 'tree' }
Pan's avatar
Pan committed
181
      }
Pan's avatar
Pan committed
182 183
    ]
  },
Pan's avatar
Pan committed
184

花裤衩's avatar
花裤衩 committed
185
  // 404 page must be placed at the end !!!
Pan's avatar
Pan committed
186
  { path: '*', redirect: '/404', hidden: true }
Pan's avatar
Pan committed
187
]
188

花裤衩's avatar
花裤衩 committed
189 190
const createRouter = () => new Router({
  // mode: 'history', // require service support
191
  scrollBehavior: () => ({ y: 0 }),
花裤衩's avatar
花裤衩 committed
192
  routes: constantRoutes
193
})
花裤衩's avatar
花裤衩 committed
194 195 196 197 198 199 200 201 202 203

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router