/**
 * @author https://gitee.com/chu1204505056/vue-admin-better （不想保留author可删除）
 * @description router全局配置，如有必要可分文件抽离，其中asyncRoutes只有在intelligence模式下才会用到，vip文档中已提供路由的基础图标与小清新图标的配置方案，请仔细阅读
 */

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: '/vab',
    component: Layout,
    redirect: '/vab',
    children: [
      {
        path: 'station',
        component: () => import('@/views/vab/station/index'),
        name: 'station',
        meta: {
          title: '场站信息',
          icon: 'info',
          permissions: ['admin'],
        },
      },
    ],
  },


  {
    path: '/quartz',
    component: Layout,
    redirect: 'noRedirect',
    name: 'Quartz',
    alwaysShow: true,
    meta: { title: '定时任务', icon: 'clock' },
    children: [
      {
        path: 'quartzInfo',
        component: () => import('@/views/quartz/quartzInfo/index'),
        name: 'quartzInfo',
        meta: {
          title: '定时任务',
          permissions: ['admin'],
        },
      },
      {
        path: 'quartzBase',
        component: () => import('@/views/quartz/quartzBase/index'),
        name: 'quartzBase',
        meta: {
          title: '任务初始',
          permissions: ['admin'],
        },
      },
    ],
  },


  {
    path: '/data',
    component: Layout,
    redirect: 'noRedirect',
    name: 'data',
    alwaysShow: true,
    meta: { title: '数据查询', icon: 'flag' },
    children: [
      {
        path: 'forecastData',
        component: () => import('@/views/data/forecastData/index'),
        name: 'forecastData',
        meta: {
          title: '功率修正',
          permissions: ['admin'],
        },
      },
      {
        path: 'backforefp',
        component: () => import('@/views/data/backforefp/index'),
        name: 'backforefp',
        meta: {
          title: '短期回传',
          permissions: ['admin'],
        },
      },

      {
        path: 'backforeusfp',
        component: () => import('@/views/data/backforeusfp/index'),
        name: 'backforeusfp',
        meta: {
          title: '超短期回传',
          permissions: ['admin'],
        },
      },

      {
        path: 'backstatdata',
        component: () => import('@/views/data/backstatdata/index'),
        name: 'backstatdata',
        meta: {
          title: '统计回传',
          permissions: ['admin'],
        },
      },

      {
        path: 'usfpcorrect',
        component: () => import('@/views/data/usfpcorrect/index'),
        name: 'usfpcorrect',
        meta: {
          title: '超短期修正',
          permissions: ['admin'],
        },
      },
      {
        path: 'rpcorrect',
        component: () => import('@/views/data/rpcorrect/index'),
        name: 'rpcorrect',
        meta: {
          title: '检修计划',
          permissions: ['admin'],
        },
      },
    ],
  },


  {
    path: '/record',
    component: Layout,
    redirect: '/record',
    children: [
      {
        path: 'record',
        name: 'record',
        component: () => import('@/views/record/index'),
        meta: {
          title: '日志', icon: 'bell',
        },
      },
    ],
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true,
  },
]

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

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

export default router
