/* * @Author: zwq * @Date: 2021-11-15 08:20:28 * @LastEditors: zwq * @LastEditTime: 2021-12-17 14:51:08 * @Description: */ /** * 全站路由配置 * * 建议: * 1. 代码中路由统一使用name属性跳转(不使用path属性) */ import Vue from 'vue' import Router from 'vue-router' import { clearLoginInfo } from '@/utils' Vue.use(Router) // 开发环境不使用懒加载, 因为懒加载页面太多的话会造成webpack热更新太慢, 所以只有生产环境使用懒加载 const _import = require('./import-' + process.env.NODE_ENV) // 全局路由(无需嵌套上左右整体布局) const globalRoutes = [ { path: '/404', component: _import('common/404'), name: '404', meta: { title: '404未找到' } }, { path: '/login', component: _import('common/login'), name: 'login', meta: { title: '登录' } } ] // 主入口路由(需嵌套上左右整体布局) const mainRoutes = { path: '/', component: _import('main'), name: 'main', redirect: { name: 'home' }, meta: { title: '主入口整体布局' }, children: [ // 通过meta对象设置路由展示方式 // 1. isTab: 是否通过tab展示内容, true: 是, false: 否 // 2. iframeUrl: 是否通过iframe嵌套展示内容, '以http[s]://开头': 是, '': 否 // 提示: 如需要通过iframe嵌套展示内容, 但不通过tab打开, 请自行创建组件使用iframe处理! { path: '/home', component: _import('common/home'), name: 'home', meta: { title: '首页', isTab: true } }, { path: '/orderProcess', component: _import('common/order-process'), name: 'orderProcess', meta: { title: '订单加工', isTab: true } }, { path: '/exWarehouse', component: _import('common/ex-warehouse'), name: 'exWarehouse', meta: { title: '货物出库', isTab: true } }, { path: '/addProcess', component: _import('common/add-process'), name: 'addProcess', meta: { title: '追加加工', isTab: true } }, { path: '/theme', component: _import('common/theme'), name: 'theme', meta: { title: '主题', isTab: true } }, { path: '/demo-echarts', component: _import('demo/echarts'), name: 'demo-echarts', meta: { title: 'demo-echarts', isTab: true } }, { path: '/demo-ueditor', component: _import('demo/ueditor'), name: 'demo-ueditor', meta: { title: 'demo-ueditor', isTab: true } }, { path: '/basic-cache', component: _import('basic/cache'), name: 'basic-cache', meta: { title: '缓存区信息', isTab: true } }, { path: '/basic-processInfo', component: _import('basic/processInfo'), name: 'basic-processInfo', meta: { title: '工艺信息', isTab: true } }, { path: '/basic-cache-location', component: _import('basic/components/location'), name: 'basic-cache-location', meta: { title: '库位信息', isTab: true } }, { path: '/basic-equipmentInfo', component: _import('basic/equipmentInfo'), name: 'basic-equipmentInfo', meta: { title: '设备基础信息', isTab: true } }, { path: '/basic-carInfo', component: _import('basic/carInfo'), name: 'basic-carInfo', meta: { title: '车辆信息', isTab: true } }, { path: '/basic-alarmInfo', component: _import('basic/alarmInfo'), name: 'basic-alarmInfo', meta: { title: '报警基础信息', isTab: true } }, { path: '/order-current-order', component: _import('order/current-order'), name: 'order-current-order', meta: { title: '当前订单列表', isTab: true } }, { path: '/order-current-order-task', component: _import('order/components/current-order-task'), name: 'order-current-order-task', meta: { title: '当前订单任务详情', isTab: true } }, { path: '/order-current-task', component: _import('order/current-task'), name: 'order-current-task', meta: { title: '当前执行任务', isTab: true } }, { path: '/order-current-task-detail', component: _import('order/components/current-task-detail'), name: 'order-current-task-detail', meta: { title: '当前执行任务详情', isTab: true } }, { path: '/report-kiln-alarm', component: _import('report/kiln-alarm'), name: 'report-kiln-alarm', meta: { title: '窑炉报警', isTab: true } }, { path: '/report-car-alarm', component: _import('report/car-alarm'), name: 'report-car-alarm', meta: { title: '车辆运行报警', isTab: true } }, { path: '/report-order-history', component: _import('report/order-history'), name: 'report-order-history', meta: { title: '订单历史列表', isTab: true } }, { path: '/report-order-history-task', component: _import('report/components/order-history-task'), name: 'report-order-history-task', meta: { title: '订单历史任务详情', isTab: true } }, { path: '/report-task-history', component: _import('report/task-history'), name: 'report-task-history', meta: { title: '执行任务历史列表', isTab: true } }, { path: '/report-task-history-detail', component: _import('report/components/task-history-detail'), name: 'report-task-history-detail', meta: { title: '执行任务历史详情', isTab: true } }, { path: '/energy-sulfur-dioxide', component: _import('energy/sulfur-dioxide'), name: 'energy-sulfur-dioxide', meta: { title: '二氧化硫流量分析', isTab: true } }, { path: '/energy-electric', component: _import('energy/electric'), name: 'energy-electric', meta: { title: '用电能源分析', isTab: true } }, { path: '/energy-kiln-electric', component: _import('energy/kiln-electric'), name: 'energy-kiln-electric', meta: { title: '窑炉用电分析', isTab: true } }, { path: '/energy-ammonia', component: _import('energy/ammonia'), name: 'energy-ammonia', meta: { title: '氨气流量分析', isTab: true } }, { path: '/energy-methanol', component: _import('energy/methanol'), name: 'energy-methanol', meta: { title: '甲醇流量分析', isTab: true } }, { path: '/energy-propane', component: _import('energy/propane'), name: 'energy-propane', meta: { title: '丙烷流量分析', isTab: true } }, { path: '/energy-nitrogen', component: _import('energy/nitrogen'), name: 'energy-nitrogen', meta: { title: '氮气流量分析', isTab: true } }, { path: '/energy-electric-acquisition', component: _import('energy/electric-acquisition'), name: 'energy-electric-acquisition', meta: { title: '电能采集数据', isTab: true } }, { path: '/energy-gas-acquisition', component: _import('energy/gas-acquisition'), name: 'energy-gas-acquisition', meta: { title: '用气采集数据', isTab: true } }, { path: '/energy-temperature-acquisition', component: _import('energy/temperature-acquisition'), name: 'energy-temperature-acquisition', meta: { title: '温度采集数据', isTab: true } }, { path: '/energy-process-temperature', component: _import('energy/process-temperature'), name: 'energy-process-temperature', meta: { title: '窑炉加工温度', isTab: true } }, { path: '/energy-sump-temperature', component: _import('energy/sump-temperature'), name: 'energy-sump-temperature', meta: { title: '油槽温度', isTab: true } }, { path: '/energy-ammonia-analysis', component: _import('energy/ammonia-analysis'), name: 'energy-ammonia-analysis', meta: { title: '使用氮气分析', isTab: true } }, { path: '/energy-kiln-speed', component: _import('energy/kiln-speed'), name: 'energy-kiln-speed', meta: { title: '窑炉速度参数', isTab: true } } ], beforeEnter (to, from, next) { let token = Vue.cookie.get('token') if (!token || !/\S/.test(token)) { clearLoginInfo() next({ name: 'login' }) } next() } } const router = new Router({ mode: 'hash', scrollBehavior: () => ({ y: 0 }), routes: globalRoutes.concat(mainRoutes) }) export default router