import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/Login.vue'),
    meta: { title: '登录' }
  },
  {
    path: '/',
    component: () => import('@/views/Layout.vue'),
    meta: { requiresAuth: true },
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/Dashboard.vue'),
        meta: { title: '生产看板', icon: 'el-icon-monitor', requiresAuth: true }
      },
      {
        path: 'material',
        name: 'Material',
        component: () => import('@/views/Material.vue'),
        meta: { title: '物料跟踪', icon: 'el-icon-box', requiresAuth: true }
      },
      {
        path: 'production',
        name: 'Production',
        component: () => import('@/views/Production.vue'),
        meta: { title: '实绩管理', icon: 'el-icon-data-analysis', requiresAuth: true }
      },
      {
        path: 'plan',
        name: 'Plan',
        component: () => import('@/views/Plan.vue'),
        meta: { title: '计划管理', icon: 'el-icon-date', requiresAuth: true }
      },
      {
        path: 'downtime',
        name: 'Downtime',
        component: () => import('@/views/Downtime.vue'),
        meta: { title: '停机管理', icon: 'el-icon-warning-outline', requiresAuth: true }
      },
      {
        path: 'equipment',
        name: 'Equipment',
        component: () => import('@/views/Equipment.vue'),
        meta: { title: '设备管理', icon: 'el-icon-set-up', requiresAuth: true }
      },
      {
        path: 'message',
        name: 'Message',
        component: () => import('@/views/Message.vue'),
        meta: { title: '报文监控', icon: 'el-icon-connection', requiresAuth: true }
      },
      {
        path: 'process-model',
        name: 'ProcessModel',
        component: () => import('@/views/ProcessModel.vue'),
        meta: { title: '工艺段模型', icon: 'el-icon-cpu', requiresAuth: true }
      },
      {
        path: 'tension-model',
        name: 'TensionModel',
        component: () => import('@/views/TensionModel.vue'),
        meta: { title: '张力设定', icon: 'el-icon-odometer', requiresAuth: true }
      },
      {
        path: 'inspection',
        name: 'Inspection',
        component: () => import('@/views/Inspection.vue'),
        meta: { title: '设备巡检', requiresAuth: true }
      },
      {
        path: 'quality',
        name: 'Quality',
        component: () => import('@/views/Quality.vue'),
        meta: { title: '质量管理', icon: 'el-icon-medal', requiresAuth: true }
      },
      {
        path: 'capacity',
        name: 'Capacity',
        component: () => import('@/views/Capacity.vue'),
        meta: { title: '产能分析', icon: 'el-icon-s-data', requiresAuth: true }
      },
    ]
  },
  { path: '*', redirect: '/' }
]

export default new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
