123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- import Vue from 'vue'
- import VueRouter from 'vue-router'
- import utils from '@/libs/utils'
- // import Home from '../views/Home.vue'
- const Login = ()=>import("@/login/Login.vue")
- const DownAllQualityReport = ()=>import("@/login/DownAllQualityReport.vue")
- const DownAppQualityReport = ()=>import("@/login/DownAppQualityReport.vue")
- const MainPage = ()=>import('@/views/MainPage.vue')
- const HomePage = ()=>import('@/views/homecomponents/HomePage.vue')
- const EquipmentMonitor = ()=>import('@/views/homecomponents/EquipmentAnalysis/EquipmentMonitor.vue')
- const AlarmMonitor = ()=>import('@/views/homecomponents/EquipmentAnalysis/AlarmMonitor.vue')
- const AlarmHandling = ()=>import('@/views/homecomponents/EquipmentAnalysis/AlarmHandling.vue')
- const PolicyConfigManage = ()=>import('@/views/homecomponents/EquipmentAnalysis/PolicyConfigManage.vue')
- const ComprehensiveQuery = ()=>import('@/views/homecomponents/EquipmentAnalysis/ComprehensiveQuery.vue')
- const LineStationManage = ()=>import('@/views/homecomponents/BasicInfomation/LineStationManage.vue')
- const ApplicationManage = ()=>import('@/views/homecomponents/BasicInfomation/ApplicationManage.vue')
- const DeviceManage = ()=>import('@/views/homecomponents/BasicInfomation/DeviceManage.vue')
- const InstruManage = ()=>import('@/views/homecomponents/BasicInfomation/InstruManage.vue')
- const OperaTimeManage = ()=>import('@/views/homecomponents/BasicInfomation/OperaTimeManage.vue')
- const Organization = ()=>import('@/views/homecomponents/SystemSettings/Organization.vue')
- const UserManagement = ()=>import('@/views/homecomponents/SystemSettings/UserManagement.vue')
- const RolePermissions = ()=>import('@/views/homecomponents/SystemSettings/RolePermissions.vue')
- const ResourceManagement = ()=>import('@/views/homecomponents/SystemSettings/ResourceManagement.vue')
- const OperationLog = ()=>import('@/views/homecomponents/SystemSettings/OperationLog.vue')
- const DataMonitor = ()=>import('@/views/homecomponents/DataManagement/DataMonitor.vue')
- const DataRules = ()=>import('@/views/homecomponents/DataManagement/DataRules.vue')
- const DataReport = ()=>import('@/views/homecomponents/DataManagement/DataReport.vue')
- Vue.use(VueRouter)
- const routes = [
- {
- path: '/',
- name: 'Login',
- component: Login,
- },
- {
- path: '/login/DownAllQualityReport',
- name: 'DownAllQualityReport',
- component: DownAllQualityReport,
- },
- {
- path: '/login/DownAppQualityReport',
- name: 'DownAppQualityReport',
- component: DownAppQualityReport,
- },
- {
- path: '/MainPage',
- component: MainPage,
- meta: { Auth: true }, // 添加该字段,表示进入这个路由是需要登录的
- beforeEnter: (to, from, next) => {
- if (!utils.storage('sw_user')) {
- next({ path: '/login' })
- return false
- }
- next()
- },
- children: [
- // 首页
- {
- path: '',
- name: 'HomePage',
- component: HomePage,
- },
- // 设备分析
- {
- path: 'EquipmentMonitor',
- name: 'EquipmentMonitor',
- component: EquipmentMonitor
- },
- {
- path: 'AlarmMonitor',
- name: 'AlarmMonitor',
- component: AlarmMonitor
- },
- {
- path: 'AlarmHandling',
- name: 'AlarmHandling',
- component: AlarmHandling
- },
- {
- path: 'PolicyConfigManage',
- name: 'PolicyConfigManage',
- component: PolicyConfigManage
- },
- {
- path: 'ComprehensiveQuery',
- name: 'ComprehensiveQuery',
- component: ComprehensiveQuery
- },
- // 基础信息
- {
- path: 'LineStationManage',
- name: 'LineStationManage',
- component: LineStationManage
- },
- {
- path: 'ApplicationManage',
- // path: '/MainPage/ApplicationManage/:type?',
- name: 'ApplicationManage',
- component: ApplicationManage
- },
- {
- path: 'DeviceManage',
- name: 'DeviceManage',
- component: DeviceManage
- },
- {
- path: 'InstruManage',
- name: 'InstruManage',
- component: InstruManage
- },
- {
- path: 'OperaTimeManage',
- name: 'OperaTimeManage',
- component: OperaTimeManage
- },
- //系统设置
- {
- path: 'Organization',
- name: 'Organization',
- component: Organization
- },
- {
- path: 'UserManagement',
- name: 'UserManagement',
- component: UserManagement
- },
- {
- path: 'RolePermissions',
- name: 'RolePermissions',
- component: RolePermissions
- },
- {
- path: 'ResourceManagement',
- name: 'ResourceManagement',
- component: ResourceManagement
- },
- {
- path: 'OperationLog',
- name: 'OperationLog',
- component: OperationLog
- },
- // 数据管理
- {
- path: 'DataMonitor',
- name: 'DataMonitor',
- component: DataMonitor
- },
- {
- path: 'DataRules',
- name: 'DataRules',
- component: DataRules
- },
- {
- path: 'DataReport',
- name: 'DataReport',
- component: DataReport
- },
- // {
- // path: 'BasicInfomation',
- // component: BasicInfomation,
- // children: [{
- // path: '',
- // name: 'StationManage',
- // component: StationManage
- // },
- // {
- // path: 'employee_search',
- // name: 'MoreSearch',
- // component: MoreSearch
- // }
- // ]
- // },
- ]
- },
- { path: '*', redirect: '/' }
- ]
- // const router = new VueRouter({
- // routes
- // })
- // 3. 创建 router 实例,然后传 `routes` 配置
- const router = new VueRouter({
- // mode: 'history',
- base: process.env.BASE_URL,
- routes,
- scrollBehavior(to, from, savedPosition) {
- return { x: 0, y: 0 }
- }
- })
- //全局前置守卫
- router.beforeEach(function (to, from, next) {
- const isAuth = to.matched.some(m => m.meta.Auth)
- if (isAuth) {
- const isLogin = utils.storage('sw_user')
- if (!isLogin) {
- next({path: '/login'})
- }
- // window._axiosPromiseArr.forEach((ele,index) => {
- // ele.cancel() // 路由跳转之前,清空(终止)上一个页面正在请求的内容
- // // 清空请求的参数 清空请求的参数
- // delete window._axiosPromiseArr[index]
- // })
- }
- next()
- })
- // 解决 Vue 重复点击相同路由 出现 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation 问题
- const originalPush = VueRouter.prototype.push
- VueRouter.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)
- }
- export default router
|