routes.js 5.52 KB
import layoutHeaderAside from '@/layout/header-aside'

// 由于懒加载页面太多的话会造成webpack热更新太慢,所以开发环境不使用懒加载,只有生产环境使用懒加载
const _import = require('@/libs/util.import.' + process.env.NODE_ENV)

/**
 * 在主框架内显示(children 由后台返回资源点集合 从 resources 中动态过滤加载)
 */
const frameIn = [{
  path: '/',
  redirect: { name: 'index' },
  component: layoutHeaderAside,
  children: []
}
]
/**
 * 首页
 */
export const home = {
  path: '/index',
  name: 'index',
  icon: 'desktop',
  meta: {
    auth: true,
    title: '系统监控',
    id: '101',
    pid: '0'
  },
  component: _import('systemMonitor')
}
export const sys = [
  // 系统 前端日志
  {
    path: '/log',
    name: 'log',
    meta: {
      title: '前端日志',
      auth: true
    },
    component: _import('system/log')
  },
  // 刷新页面 必须保留
  {
    path: '/refresh',
    name: 'refresh',
    hidden: true,
    component: _import('system/function/refresh')
  },
  // 页面重定向 必须保留
  {
    path: 'redirect/:route*',
    name: 'redirect',
    hidden: true,
    component: _import('system/function/redirect')
  }
]

/**
 * 所有需动态过滤的资源点
 */
export const resources = {
  '102': {
    path: '/page',
    icon: 'folder-o',
    name: '页面',
    meta: {
      auth: true,
      title: '页面',
      id: '102',
      pid: '0',
      cache: true
    }
  },
  '10201': {
    path: '/page1',
    name: 'page1',
    meta: {
      auth: true,
      title: '页面 1',
      id: '10201',
      pid: '102',
      cache: true
    },
    component: _import('demo/page1')
  },
  '10202': {
    path: '/page2',
    name: 'page2',
    meta: {
      auth: true,
      title: '页面 2',
      id: '10202',
      pid: '102',
      cache: true
    },
    component: _import('demo/page2'),
    auth: {
      'operation': [{ // 列表操作
        id: '1020201',
        pid: '10202',
        label: '查看'
      }, { //
        id: '1020202',
        pid: '10202',
        label: '编辑'
      }],
      'action': [] // 按钮操作
    }
  },
  '10203': {
    path: '/page3',
    name: '页面 3',
    meta: {
      auth: true,
      title: '页面 3',
      id: '10203',
      pid: '102'
    },
    auth: {
      'operation': [{ // 列表操作
        id: '1020301',
        pid: '10203',
        label: '查看'
      }, { //
        id: '1020302',
        pid: '10203',
        label: '编辑'
      }],
      'action': [] // 按钮操作
    },
    component: _import('demo/page3')
  },
  // '102': {
  //   path: 'trafficManagement',
  //   icon: 'train',
  //   name: '车辆管理',
  //   meta: {
  //     auth: true,
  //     title: '车辆管理',
  //     id: '102',
  //     pid: '0'
  //   },
  //   component: _import('trafficManagement')
  // },
  '103': {
    path: '/subSysManagement',
    icon: 'th-list',
    name: '子系统管理',
    meta: {
      auth: true,
      title: '子系统管理',
      id: '103',
      pid: '0'
    },
    component: _import('subSysManagement')
  },
  '104': {
    path: '/trafficManagement',
    icon: 'train',
    name: '车辆管理',
    meta: {
      auth: true,
      title: '物料管理',
      id: '104',
      pid: '0'
    },
    component: _import('deviceManagement')
  },
  '105': {
    path: '/bb',
    icon: 'file-text-o',
    name: '单据管理',
    meta: {
      auth: true,
      title: '单据管理',
      id: '106',
      pid: '0'
    }
  },
  '10601': {
    path: '/materiaOrderManagement',
    icon: 'archive',
    name: '物料订单管理',
    meta: {
      auth: true,
      title: '物料订单管理',
      id: '10601',
      pid: '106'
    },
    component: _import('materiaOrderManagement')
  },
  '10602': {
    path: '/maintainManagement',
    icon: 'list-ol',
    name: '作业单管理',
    meta: {
      auth: true,
      title: '作业单管理',
      id: '10602',
      pid: '106'
    },
    component: _import('maintainManagement')
  },
  '107': {
    path: '/user',
    icon: 'users',
    name: '用户管理',
    meta: {
      auth: true,
      title: '用户管理',
      id: '107',
      pid: '0'
    }
  },
  '10701': {
    path: '/userManage',
    name: '用户管理',
    icon: 'user',
    meta: {
      auth: true,
      title: '用户管理',
      id: '10701',
      pid: '107'
    },
    component: _import('userManage/loginLogs')
  },
  '10702': {
    path: '/jurisdictionManage',
    name: '权限管理',
    icon: 'sitemap',
    meta: {
      auth: true,
      title: '权限管理',
      id: '10702',
      pid: '107'
    },
    component: _import('userManage/loginLogs')
  },
  '10703': {
    path: '/loginLogs',
    name: '登录日志',
    icon: 'file-text',
    meta: {
      auth: true,
      title: '登录日志',
      id: '10703',
      pid: '107'
    },
    component: _import('userManage/loginLogs')
  },
  '108': {
    path: '/reportingLogs',
    icon: 'upload',
    name: '上报日志',
    meta: {
      auth: true,
      title: '上报日志',
      id: '108',
      pid: '0'
    },
    component: _import('reportingLogs')
  }
}

/**
 * 在主框架之外显示
 */
const frameOut = [
  // 登录
  {
    path: '/login',
    name: 'login',
    component: _import('system/login')
  }
]

/**
 * 错误页面
 */
export const errorPage = {
  path: '*',
  name: '404',
  component: _import('system/error/404')
}

// 导出需要显示菜单的
export const frameInRoutes = frameIn

// 重新组织后导出
export default [
  // ...resources,
  // ...frameIn,
  // dashboard,
  ...frameOut,
  errorPage
]