144 lines
3.3 KiB
JavaScript
144 lines
3.3 KiB
JavaScript
import Vue from 'vue'
|
|
import VueRouter from 'vue-router'
|
|
import cookies from "js-cookie";
|
|
import Layout from '@/components/Layout.vue'
|
|
|
|
Vue.use(VueRouter)
|
|
|
|
const routes = [
|
|
|
|
|
|
{
|
|
path: '/',
|
|
//name: 'layout',
|
|
component: Layout,
|
|
children: [
|
|
{
|
|
path: '/login',
|
|
name: 'login',
|
|
meta: {
|
|
title: '系统登录',
|
|
showMenu: false,
|
|
},
|
|
component: () => import('@/views/login/index.vue')
|
|
},{
|
|
path: '/home', //
|
|
name: 'home',
|
|
meta: {
|
|
title: '首页'
|
|
},
|
|
component: () => import('@/views/home/index.vue'),
|
|
},{
|
|
path: '/flow/device', //
|
|
name: 'flow',
|
|
meta: {
|
|
title: '车检器'
|
|
},
|
|
component: () => import('@/views/flow/device.vue'),
|
|
},{
|
|
path: '/flow/planHistory', //
|
|
name: 'planHistory',
|
|
meta: {
|
|
title: '预案历史'
|
|
},
|
|
component: () => import('@/views/flow/planHistory.vue'),
|
|
},/*{
|
|
path: '/', //
|
|
name: 'control',
|
|
meta: {
|
|
title: '控制中心'
|
|
},
|
|
component: () => import('@/views/control/index.vue'),
|
|
},*/{
|
|
path: '/device/management', //
|
|
name: 'device',
|
|
meta: {
|
|
title: '设备管理'
|
|
},
|
|
component: () => import('@/views/device/index.vue'),
|
|
},{
|
|
path: '/device/view', //
|
|
name: 'device',
|
|
meta: {
|
|
title: '设备可视化'
|
|
},
|
|
component: () => import('@/views/device/deviceView.vue'),
|
|
},{
|
|
path: '/config/devicePlan', //
|
|
name: 'devicePlan',
|
|
meta: {
|
|
title: '设备联动预案'
|
|
},
|
|
component: () => import('@/views/config/devicePlan.vue'),
|
|
},{
|
|
path: '/user/userManagement',
|
|
name: '用户管理',
|
|
meta: {
|
|
title: '用户管理'
|
|
},
|
|
component: () => import('@/views/systemManagement/userManagement.vue'),
|
|
},{
|
|
path: '/role/roleManagement',
|
|
name: '角色管理',
|
|
meta: {
|
|
title: '角色管理'
|
|
},
|
|
component: () => import('@/views/systemManagement/roleManagement.vue'),
|
|
},{
|
|
path: '/depart/departManagement',
|
|
name: '部门管理',
|
|
meta: {
|
|
title: '部门管理'
|
|
},
|
|
component: () => import('@/views/systemManagement/departManagement.vue'),
|
|
},{
|
|
path: '/log/logManagement',
|
|
name: '日志管理',
|
|
meta: {
|
|
title: '部门管理'
|
|
},
|
|
component: () => import('@/views/systemManagement/logManagement.vue'),
|
|
},{
|
|
path: '/',
|
|
name: 'view',
|
|
meta: {
|
|
title: '可视化'
|
|
},
|
|
component: () => import('@/views/view/index.vue'),
|
|
}]
|
|
},{
|
|
path: '/test2',
|
|
name: '首页',
|
|
meta: {
|
|
title: '首页'
|
|
},
|
|
component: () => import('@/views/test2.vue'),
|
|
}
|
|
]
|
|
|
|
//以下代码解决路由地址重复点击的报错问题
|
|
/*const originalPush = VueRouter.prototype.push
|
|
VueRouter.prototype.push = function push(location) {
|
|
return originalPush.call(this, location).catch(err => err)
|
|
}*/
|
|
|
|
const router = new VueRouter({
|
|
mode: 'hash',
|
|
base: '/dist/',
|
|
routes
|
|
})
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
let myCookie = cookies.get('PORTAL_TOKEN');
|
|
/*if(to.path == '/'){
|
|
next();
|
|
}else*/
|
|
if (!myCookie && to.path != '/login') {
|
|
router.push({path: '/login'});
|
|
} else {
|
|
next();
|
|
}
|
|
});
|
|
|
|
export default router
|