import { UserLayout, TabLayout, RouteView, BlankLayout, PageView } from '@/components/layouts'

/**
 * 走菜单，走权限控制
 * @type {[null,null]}
 */
export const asyncRouterMap = [

  {
    path: '/',
    name: 'dashboard',
    component: TabLayout,
    meta: { title: '首页' },
    redirect: '/dashboard/analysis',
    children: [
      {
        path: '/workOrder',
        component: RouteView,
        meta: { title: '工单管理', icon: 'profile' },
        children: [
          {
            path: '/workOrder/workOrderList',
            name: 'WorkOrderList',
            component: () => import('@/views/workOrder/WorkOrderList.vue'),
            meta: { title: '任务工单' }
          }
        ]
      },
      {
        path: '/plan',
        component: RouteView,
        meta: { title: '计划管理', icon: 'calendar' },
        children: [
          {
            path: '/plan/planList',
            name: 'PlanList',
            component: () => import('@/views/plan/PlanList.vue'),
            meta: { title: '检修计划' }
          }
        ]
      },
      {
        path: '/workflow',
        component: RouteView,
        meta: { title: '流程管理', icon: 'apartment' },
        children: [
          {
            path: '/workFlow/workspace/todo',
            name: 'Todo',
            component: () => import('@/views/workFlow/workspace/todo/index.vue'),
            meta: { title: '流程管理' }
          }
        ]
      },
      {
        path: '/indexTest',
        component: RouteView,
        meta: { title: '设备监控', icon: 'sliders' },
        children: [
          {
            path: '/dashboard/indexTest',
            name: 'IndexTest',
            component: () => import('@/views/dashboard/IndexTest.vue'),
            meta: { title: '实时数据' }
          }
        ]
      }
    ]
  },
  {
    path: '*', redirect: '/404', hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@views/user/Login')
      },
      {
        path: 'register',
        name: 'register',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/register/Register')
      },
      {
        path: 'register-result',
        name: 'registerResult',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/register/RegisterResult')
      },
      {
        path: 'alteration',
        name: 'alteration',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/alteration/Alteration')
      },
    ]
  },
  {
    path: '/screen',
    component: () => import('@/views/screen/index.vue')
  },

  // {
  //   path: '/',
  //   name: 'index',
  //   component: TabLayout,
  //   meta: {title: '首页'},
  //   redirect: '/dashboard/workplace',
  //   children: [
  //     {
  //       path: '/online',
  //       name: 'online',
  //       redirect: '/online',
  //       component: RouteView,
  //       meta: {title: '在线开发', icon: 'dashboard', permission: ['dashboard']},
  //       children: [
  //         {
  //           path: '/online/auto/:code',
  //           name: 'report',
  //           component: () => import('@/views/modules/online/cgreport/OnlCgreportAutoList')
  //         },
  //       ]
  //     },
  //   ]
  // },

  {
    // OAuth2 APP页面路由
    path: '/oauth2-app',
    component: BlankLayout,
    redirect: '/oauth2-app/login',
    children: [
      {
        // OAuth2 登录路由
        path: 'login',
        name: 'oauth2-app-login',
        component: () => import(/* webpackChunkName: "oauth2-app.login" */ '@/views/user/oauth2/OAuth2Login')
      },
    ]
  },

  {
    path: '/homescreen',
    name: 'homescreen',
    component: () => import('@views/dashboard/homescreen.vue'),
    meta: {
      requiresAuth: false,  // 明确不需要登录[1,6](@ref)
      hidden: true,        // 隐藏菜单
      hideLayout: true,    // 隐藏所有布局元素
    }
  },

  {
    path: '/test',
    component: BlankLayout,
    redirect: '/test/home',
    children: [
      {
        path: 'home',
        name: 'TestHome',
        component: () => import('@/views/Home')
      }
    ]
  },
  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  },
  // {
  //   path: '/header',
  //   component: () => import(/* webpackChunkName: "fail" */ '@/views/device/BuDeviceOnlineList')
  // },
]
