import Vue from 'vue' import Router from 'vue-router' import {beforeEach, pageRoutes, setConfig} from './router/router' import store from '../packages/store' Vue.use(Router) // const originalPush = Router.prototype.push // // Router.prototype.push = function push(location) { // // return originalPush.call(this, location) // // } const originalPush = Router.prototype.push Router.prototype.push = function push(location, onResolve, onReject) { if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject) return originalPush.call(this, location).catch(err => err) } // 视频播放页 pageRoutes.push({ path: '/userHelp', name: 'userHelp', meta: {title: '帮助页', isTab: true}, component: () => import('./views/modules/userHelp/userHelp') }) // 登录页 pageRoutes.push({ path: '/login', name: 'login', meta: {title: '首页', isTab: true}, component: () => import('./views/pages/login') }) // 登录页 pageRoutes.push({ path: '/index', name: 'index', meta: {title: '首页', isTab: true}, component: () => import('./views/pages/login') }) // 模块路由(基于主入口布局页面) const moduleRoutes = { path: '/', component: () => import('./views/layout/main'), name: 'main', redirect: {name: 'index'}, meta: {title: '门户'}, children: [ // { // path: '/sys-menu', // component: () => import('.././packages/views/modules/sys/menu'), // name: 'SYS_MENU', // meta: {title: '菜单管理', isTab: true} // }, {path: '/home', component: () => import('./views/modules/sys/task/taskCenter'), name: 'home', meta: {title: '首页', isTab: true} } ] } const router = new Router({ mode: 'hash', scrollBehavior: () => ({y: 0}), routes: pageRoutes.concat(moduleRoutes) }) // 配置router setConfig(router, moduleRoutes, (url) => import(`./views/modules/${url}`)) router.beforeEach((to, from, next) => { if(to.name == 'sys-sysPage-digitalData-home' || to.name == 'sys-sysPage-replace-home' || to.name == 'sys-sysPage-equipment-home' || to.name == 'sys-sysPage-technology-home' ){ store.state.marginTop = true store.state.horizontalRouter = false store.state.auiWrapperWidth= true store.state.showHeader = false store.state.horizontalHide = true }else { store.state.marginTop = false store.state.auiWrapperWidth= false store.state.showHeader = true store.state.horizontalRouter = true store.state.horizontalHide = false } beforeEach(to, from, next) }) // router.beforeEach((to, from, next) => { // store.state.showHeader = to.name !== 'sys-sysPage-digitalData-home' // beforeEach(to, from, next) // }) export default router