import Vue from 'vue' import Router from 'vue-router' import { getSession, message } from './../util/item' const routerPush = Router.prototype.push Router.prototype.push = function push(location) { return routerPush.call(this, location).catch(error=> error) } import Login from '@/components/login' import Index from '@/components/index' import Overview from '@/components/overview'//概览页面 import PreviewOfSiteStatus from '@/components/site/previewOfSiteStatus' //站点状况预览图 import NewFiberSearch from '@/components/newFiber/NewFiberSearch' //新烽查询系统 // 配置中心 import AlarmConfiguration from '@/components/configure/AlarmConfiguration' //报警配置 import PushRules from '@/components/configure/PushRules' //推送规则 import AlarmLog from '@/components/configure/AlarmLog' //推送规则 import PatrolConfiguration from '@/components/configure/PatrolConfiguration' //巡检配置 // 消息管理 import MessageQuery from '@/components/MessageManagement/MessageQuery' //消息查询 import MessageStatistics from '@/components/MessageManagement/MessageStatistics' //消息统计 // 数据分析 import DataScreening from '@/components/DataAnalysis/dataScreening' //数据总览 import StatisticalReport from '@/components/DataAnalysis/StatisticalReport' //统计报表 // 工业物联网云平台 import VideoSurveillance from '@/components/NFCloudPlatform/VideoSurveillance' //视频监控 // import GroundFloor from '@/components/NFCloudPlatform/GroundFloor' //视频监控-一楼泵站 // import Attic from '@/components/NFCloudPlatform/Attic' //视频监控-顶楼泵站 import RealTime from '@/components/NFCloudPlatform/RealTime' //实时监控 // 工程作业 import Nowfault from '@/components/Engineering/Nowfault' //查询实时故障数据 import HistoricalFault from '@/components/Engineering/HistoricalFault' //查询历史故障数据 import MyHomework from '@/components/Engineering/MyHomework' //我的作业 // LED import LEDConfig from '@/components/LED/LEDConfig';//LED屏 // 系统管理 import user from '@/components/sys/user';//用户管理 import menu from '@/components/sys/menu';//菜单管理 import org from '@/components/sys/org';//组织管理 import role from '@/components/sys/role';//角色管理 // 芯中心状态监控 import ConditionMonitoring from '@/components/ConditionMonitoring/ConditionMonitoring'; Vue.use(Router) import axios from 'axios' import qs from 'qs' Vue.prototype.$axios = axios //全局注册,使用方法为:this.$axios Vue.prototype.qs = qs //全局注册,使用方法为:this.qs const router = new Router({ routes: [{ path: '/index', name: 'index', component: Index, children: [{ path: '/overview', name: 'overview', component: Overview },{ path: '/site/previewOfSiteStatus',//站点状况预览图--站点状况预览图 name: 'PreviewOfSiteStatus', component: PreviewOfSiteStatus },{ path: '/newFiber/NewFiberSearch',//新烽查询系统 name: 'NewFiberSearch', component: NewFiberSearch },{ path: '/configure/AlarmConfiguration',// 配置中心--报警配置 name: 'AlarmConfiguration', component: AlarmConfiguration },{ path: '/configure/PushRules',// 配置中心--推送规则 name: 'PushRules', component: PushRules },{ path: '/configure/AlarmLog',// 配置中心--报警日志 name: 'AlarmLog', component: AlarmLog },{ path: '/configure/PatrolConfiguration',// 配置中心--巡检配置 name: 'PatrolConfiguration', component: PatrolConfiguration },{ path: '/MessageManagement/MessageQuery',// 消息管理--消息查询 name: 'MessageQuery', component: MessageQuery },{ path: '/MessageManagement/MessageStatistics',// 消息管理--消息统计 name: 'MessageStatistics', component: MessageStatistics },{ path: '/DataAnalysis/dataScreening',// 数据分析--数据总览 name: 'DataScreening', component: DataScreening },{ path: '/DataAnalysis/StatisticalReport',// 数据分析--统计报表 name: 'StatisticalReport', component: StatisticalReport },{ path: '/NFCloudPlatform/VideoSurveillance',// 工业物联网云平台--视频监控 name: 'VideoSurveillance', component: VideoSurveillance }, // { // path: '/NFCloudPlatform/GroundFloor',// 工业物联网云平台--视频监控-一楼泵站 // name: 'GroundFloor', // component: GroundFloor // },{ // path: '/NFCloudPlatform/Attic',// 工业物联网云平台--视频监控-顶楼泵站 // name: 'Attic', // component: Attic // }, { path: '/NFCloudPlatform/RealTime',// 工业物联网云平台--实时监控 name: 'RealTime', component: RealTime },{ path: '/Engineering/Nowfault',// 查询实时故障数据 name: 'Nowfault', component: Nowfault },{ path: '/Engineering/HistoricalFault',// 查询历史故障数据 name: 'HistoricalFault', component: HistoricalFault },{ path: '/Engineering/MyHomework',// 查询历史故障数据 name: 'MyHomework', component: MyHomework },{ path: '/LED/LEDConfig',//LED屏 name: 'LEDConfig', component: LEDConfig },{ path: '/sys/user',//用户管理 name: 'user', component: user },{ path: '/sys/menu',//菜单管理 name: 'menu', component: menu },{ path: '/sys/org',//组织信息 name: 'org', component: org },{ path: '/sys/role',//角色管理 name: 'role', component: role },{ path: '/ConditionMonitoring/ConditionMonitoring',//芯中心状态监控 name: 'ConditionMonitoring', component: ConditionMonitoring },] },{ path: '/Login', name: 'login', component: Login }, { path: '/', redirect: "/Login" }, { path: "*", redirect: "/" } ] }) router.beforeEach((to, from, next) => { /* 使用过程为, 先判断vuex里面一条数据, 判断是否登陆 */ if (to.name == 'login') { next(); } else if (JSON.parse(getSession('logins')) == 'true') { next(); } else { message({ 'data': { 'code': 1, 'message': '登录已过期,请重新登录!' } }); next({ 'path': '/Login' }); } }); export default router;