import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/layouts'
import EmptyLayout from '@/layouts/EmptyLayout'
import { publicPath, routerMode } from '@/config'

Vue.use(VueRouter)
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true,
  },
  {
    path: '/register',
    component: () => import('@/views/register/index'),
    hidden: true,
  },
  {
    path: '/401',
    name: '401',
    component: () => import('@/views/401'),
    hidden: true,
  },
  {
    path: '/404',
    name: '404',
    component: () => import('@/views/404'),
    hidden: true,
  },
]

export const asyncRoutes = [
  {
    path: '/',
    component: Layout,
    redirect: '/index',
    children: [
      {
        path: 'index',
        name: 'Index',
        component: () => import('@/views/index/index'),
        meta: {
          title: '计划电量',
          icon: 'home',
          affix: true,
        },
      },
    ],
  },

  {
    path: "/indicators",
    component: Layout,
    redirect: "noRedirect",
    children: [
      {
        path: "indicators",
        name: "indicators",
        component: () => import("@/views/indicators/index"),
        meta: {
          title: "指标录入",
          icon: "marker",
          permissions: ["admin"],
        },
      },
    ],
  },
  {
    path: '/stationConfiguration',
    component: Layout,
    redirect: 'noRedirect',
    name: 'stationConfiguration',
    meta: { title: '场站配置', icon: 'tools', permissions: ['admin'] },
    children: [
      {
        path: 'company',
        name: 'company',
        component: () =>
          import('@/views/stationConfiguration/company/index'),
        meta: { title: '公司管理' },
      },
      {
        path: 'area',
        name: 'area',
        component: () =>
          import('@/views/stationConfiguration/area/index'),
        meta: { title: '区域管理' },
      },
      {
        path: 'station',
        name: 'station',
        component: () =>
          import('@/views/stationConfiguration/station/index'),
        meta: { title: '场站管理' },
      },
      {
        path: 'period',
        name: 'period',
        component: () =>
          import('@/views/stationConfiguration/period/index'),
        meta: { title: '期次管理' },
      },
      {
        path: 'line',
        name: 'line',
        component: () =>
          import('@/views/stationConfiguration/line/index'),
        meta: { title: '线路管理' },
      },
      {
        path: 'windterbin',
        name: 'windterbin',
        component: () =>
          import('@/views/stationConfiguration/windterbin/index'),
        meta: { title: '风机管理' },
      },
    ],
  },
  {
    path: "/pointConfiguration",
    component: Layout,
    redirect: "noRedirect",
    children: [
      {
        path: "pointConfiguration",
        name: "pointConfiguration",
        component: () => import("@/views/pointConfiguration/index"),
        meta: {
          title: "测点配置",
          icon: "allergies",
          permissions: ["admin"],
        },
      },
    ],
  },
  // {
  //   path: "/equipmentAllocation",
  //   component: Layout,
  //   redirect: "noRedirect",
  //   children: [
  //     {
  //       path: "equipmentAllocation",
  //       name: "equipmentAllocation",
  //       component: () => import("@/views/pointConfiguration/equipmentAllocation/index"),
  //       meta: {
  //         title: "设备点表配置",
  //         icon: "marker",
  //         permissions: ["admin"],
  //       },
  //     },
  //   ],
  // },
  // {
  //   path: "/stationAllocation",
  //   component: Layout,
  //   redirect: "noRedirect",
  //   children: [
  //     {
  //       path: "stationAllocation",
  //       name: "stationAllocation",
  //       component: () => import("@/views/pointConfiguration/stationAllocation/index"),
  //       meta: {
  //         title: "场站点表配置",
  //         icon: "marker",
  //         permissions: ["admin"],
  //       },
  //     },
  //   ],
  // },
  // {
  //   path: '/personnelManagement',
  //   component: Layout,
  //   redirect: 'noRedirect',
  //   name: 'PersonnelManagement',
  //   meta: { title: '配置', icon: 'users-cog', permissions: ['admin'] },
  //   children: [
  //     {
  //       path: 'userManagement',
  //       name: 'UserManagement',
  //       component: () =>
  //         import('@/views/personnelManagement/userManagement/index'),
  //       meta: { title: '用户管理' },
  //     },
  //     {
  //       path: 'roleManagement',
  //       name: 'RoleManagement',
  //       component: () =>
  //         import('@/views/personnelManagement/roleManagement/index'),
  //       meta: { title: '角色管理' },
  //     },
  //     {
  //       path: 'menuManagement',
  //       name: 'MenuManagement',
  //       component: () =>
  //         import('@/views/personnelManagement/menuManagement/index'),
  //       meta: { title: '菜单管理' },
  //     },
  //   ],
  // },
  // {
  //   path: '/error',
  //   component: EmptyLayout,
  //   redirect: 'noRedirect',
  //   name: 'Error',
  //   meta: { title: '错误页', icon: 'bug' },
  //   children: [
  //     {
  //       path: '401',
  //       name: 'Error401',
  //       component: () => import('@/views/401'),
  //       meta: { title: '401' },
  //     },
  //     {
  //       path: '404',
  //       name: 'Error404',
  //       component: () => import('@/views/404'),
  //       meta: { title: '404' },
  //     },
  //   ],
  // },
]

const router = new VueRouter({
  base: publicPath,
  mode: routerMode,
  scrollBehavior: () => ({
    y: 0,
  }),
  routes: constantRoutes,
})

export function resetRouter() {
  location.reload()
}

export default router
