123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- import Vue from 'vue'
- import VueRouter from 'vue-router'
- import store from '@/store'
- Vue.use(VueRouter)
- const routes = [
- {
- path: '/login',
- name: 'Login',
- component: () => import('@/views/login/Login.vue'),
- },
- {
- path: '/',
- // redirect: '/stationMapTKT',//托克托
- redirect: '/basePage',//都匀
- },
- {
- path: '/stationMap',
- name: 'stationMap',
- component: () => import('@/views/stationMap/index.vue'),
- },
- {
- path: '/stationMapTKT',
- name: 'stationMapTKT',
- component: () => import('@/views/stationMapTKT/index.vue'),
- },
- {
- path: '/basePage',
- name: 'basePage',
- component: () => import('@/views/basePage/index.vue'),
- },
- {
- path: '/videoMonitor',
- name: 'videoMonitor',
- component: () => import('@/views/videoMonitor/index.vue'),
- },
- {
- path: '/videoMonitorType',
- name: 'videoMonitorType',
- component: () => import('@/views/videoMonitorType/index.vue'),
- },
- {
- path: '/page1',
- name: 'page1',
- component: () => import('@/views/page1/index.vue'),
- },
- {
- path: '/page2',
- name: 'page2',
- component: () => import('@/views/page2/index.vue'),
- },
- {
- path: '/alarmList',
- name: 'alarmList',
- component: () => import('@/views/alarm/alarmList/index.vue'),
- },
- {
- path: '/alarmInvalidList',
- name: 'alarmInvalidList',
- component: () => import('@/views/alarm/alarmInvalidList/index.vue'),
- },
- {
- path: '/alarmStatistics',
- name: 'alarmStatistics',
- component: () => import('@/views/alarm/alarmStatistics/index.vue'),
- },
- {
- path: '/alarmLevel',
- name: 'alarmLevel',
- component: () => import('@/views/alarm/alarmLevel/index.vue'),
- },
- {
- path: '/intelligentAnalysisList',
- name: 'intelligentAnalysisList',
- component: () => import('@/views/alarm/intelligentAnalysisList/index.vue'),
- },
- {
- path: '/tabPage',
- name: 'tabPage',
- component: () => import('@/views/tabPage/index.vue'),
- },
- {
- path: '/tabsPage',
- name: 'tabsPage',
- component: () => import('@/views/tabPage/tabPageContainer.vue'),
- },
- {
- path: '/flowChart',
- name: 'flowChart',
- component: () => import('@/views/process/flowChart/index.vue'),
- meta: { name: '流程图' },
- },
- {
- path: '/trendChart',
- name: 'trendChart',
- component: () => import('@/views/process/trendChart/index.vue'),
- meta: { name: '流程图' },
- },
- ]
- const router = new VueRouter({
- routes,
- })
- // 登录验证
- router.beforeEach(async (to, from, next) => {
- // next();
- // return;
- let token
- if (to.query.token) {
- localStorage.setItem('token', to.query.token)
- token = to.query.token
- } else {
- token = localStorage.getItem('token')
- }
- if (!token && to.name !== 'Login') {
- // Message({
- // message: "无访问权限,请先登录!",
- // type: "error",
- // duration: 800
- // });
- next('/login')
- } else {
- console.log(to.name)
- console.log(from.name)
- // 从其他页面跳转到模型页,
- // if (from.name !== 'basePage' && to.name === 'basePage') {
- // const buildId = localStorage.getItem('buildId')
- // if (!!buildId) {
- // await store.dispatch('model/setBuildInfoByBuildId', buildId)
- // }
- // }
- // 页面刷新问题(页面刷新from.name是null)
- // if (!from.name && !!to.name) {
- // const buildId = localStorage.getItem('buildId')
- // if (!!buildId) {
- // await store.dispatch('model/setBuildInfoByBuildId', buildId)
- // }
- // }
- next()
- }
- })
- const originalPush = VueRouter.prototype.push
- //修改原型对象中的push方法
- VueRouter.prototype.push = function push(location) {
- return originalPush.call(this, location).catch(err => err)
- }
- export default router
|