You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
duoji-frontend/src/router/index.js

133 lines
3.4 KiB
JavaScript

6 years ago
import Vue from 'vue'
import VueRouter from 'vue-router'
6 years ago
// const files = require.context('@/views', true, /-router\.js$/)
// let allRouter = [];
// // 匹配成功的名字数组
// files.keys().map(key => {
// allRouter = allRouter.concat(files(key).default)
// })
// allRouter.sort((a, b) => {
// return a.meta.sort - b.meta.sort
// })
6 years ago
6 years ago
// console.log(allRouter)
6 years ago
Vue.use(VueRouter)
// 避免冗余导航 (重复点击菜单栏报错问题)
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
const routes = [{
6 years ago
path: '/',
redirect: {
name: 'realTimeMonitoring'
},
component: () => import('@/views/index'),
6 years ago
children: [
{
path: 'realTimeMonitoring',
name: 'realTimeMonitoring',
6 years ago
meta: {
icon: 'desktop',
name: '实时监控'
},
component: () => import('@/views/realTimeMonitoring/index'),
},
// {
// path: 'realTimeMonitoring/model',
// name: 'camodel',
// meta: {
// name: '球机操作'
// },
// component: () => import('@/views/realTimeMonitoring/model')
// },
{
path: 'historyMonitoring',
name: 'historyMonitoring',
meta: {
icon: 'line-chart',
6 years ago
name: '历史监控'
},
component: () => import('@/views/historyMonitoring/index')
}, {
path: 'roadwayManage',
name: 'roadwayManage',
meta: {
icon: 'build',
name: '巷道管理'
},
component: () => import('@/views/roadwayManage/index')
6 years ago
}, {
path: 'cameraManage',
name: 'cameraManage',
meta: {
icon: 'video-camera',
name: '球机管理'
},
component: () => import('@/views/cameraManage/index')
},{
6 years ago
path: 'center',
name: 'center',
meta: {
name: '个人中心'
},
component: () => import('@/views/center')
}
]
6 years ago
},
{
path: '/guide',
name: 'guide',
component: () => import('../views/guide.vue')
},
{
path: '*',
name: '404',
component: () => import('../views/404.vue')
}
6 years ago
]
const router = new VueRouter({
routes
})
router.beforeEach((to, from, next) => {
6 years ago
next()
// let userInfo = JSON.parse(sessionStorage.getItem('userInfo') || '{}')
// // 校验是否登录
// if (userInfo.id) {
// // 匹配不到 404
// if (!to.name) next();
// // 权限
// if (userInfo.permissionList.some((item) => {
// return item.rights === to.name
// })) {
// next()
// } else {
// if (to.name === 'login') {
// next()
// } else {
// Vue.prototype.$message.info('没有权限')
// next(false)
// }
// }
// } else {
// if (to.name === 'login') {
// next()
// } else if (to.name !== 'login') {
// Vue.prototype.$message.info('请先登录')
// next('/login')
// } else {
// next('/login')
// }
// }
6 years ago
})
export default router