import {
  createRouter,
  createWebHistory,
  createWebHashHistory,
} from "vue-router";
import Home from "../pages/Home.vue";
const routes = [
  {
    path: "/",
    redirect: "/dataFilter/prepare",
  },
  {
    path: "/",
    name: "Home",
    redirect: "/dataFilter/prepare",
    component: Home,
    children: [
      {
        icon: "iconfont iconbaojingpeizhi",
        path: "/dataFilter",
        name: "dataFilter",
        redirect: "/dataFilter/prepare",
        meta: {
          title: "数据准备",
        },
        component: () => import("../pages/routerViewss.vue"),
        children: [
          {
            icon: "el-icon-s-home",
            path: "/dataFilter/prepare",
            name: "dataFilterPrepare",
            meta: {
              title: "风电数据准备",
            },
            component: () => import("../pages/dataFilter/prepare/index.vue"),
          },
          {
            icon: "el-icon-s-home",
            path: "/dataFilter/process",
            name: "dataFilterProcess",
            meta: {
              title: "风电数据处理",
            },
            component: () => import("../pages/dataFilter/process/index.vue"),
          },
          {
            icon: "el-icon-s-home",
            path: "/dataFilter/lightPrepare",
            name: "dataFilterLightPrepare",
            meta: {
              title: "光伏数据准备",
            },
            component: () =>
              import("../pages/dataFilter/lightPrepare/index.vue"),
          },
        ],
      },
      {
        icon: "iconfont iconbaojingpeizhi",
        path: "/dataAnalysis",
        name: "dataAnalysis",
        redirect: "/dataAnalysis/combine",
        meta: {
          title: "风电分析",
        },
        component: () => import("../pages/routerViewss.vue"),
        children: [
          {
            icon: "el-icon-s-home",
            path: "/dataAnalysis/combine",
            name: "dataAnalysis",
            meta: {
              title: "功率曲线拟合分析",
            },
            component: () => import("../pages/dataAnalysis/combine/index.vue"),
          },
          {
            icon: "el-icon-s-home",
            path: "/dataAnalysis/rateAnalysis",
            name: "dataAnalysisRateAnalysis",
            meta: {
              title: "对风偏差分析",
            },
            component: () =>
              import("../pages/dataAnalysis/rateAnalysis/index.vue"),
          },
          {
            icon: "el-icon-s-home",
            path: "/dataAnalysis/lineAnalysis",
            name: "dataAnalysislineAnalysis",
            meta: {
              title: "曲线偏差率分析",
            },
            component: () =>
              import("../pages/dataAnalysis/lineAnalysis/index.vue"),
          },
          {
            icon: "el-icon-s-home",
            path: "/dataAnalysis/hotAnalysis",
            name: "dataAnalysisthotAnalysis",
            meta: {
              title: "温度与功率分析",
            },
            component: () =>
              import("../pages/dataAnalysis/hotAnalysis/index.vue"),
          },
          {
            icon: "el-icon-s-home",
            path: "/dataAnalysis/windAnalysis",
            name: "dataAnalysisWindAnalysis",
            meta: {
              title: "损失电量分析",
            },
            component: () =>
              import("../pages/dataAnalysis/windAnalysis/index.vue"),
          },
          {
            icon: "el-icon-s-home",
            path: "/dataAnalysis/posAnalysis",
            name: "dataAnalysisPosAnalysis",
            meta: {
              title: "微观选址分析",
            },
            component: () =>
              import("../pages/dataAnalysis/posAnalysis/index.vue"),
          },
          {
            icon: "el-icon-s-home",
            path: "/dataAnalysis/spaceAnalysis",
            name: "dataAnalysisspaceAnalysis",
            meta: {
              title: "毛容量分析",
            },
            component: () =>
              import("../pages/dataAnalysis/spaceAnalysis/index.vue"),
          },
          {
            icon: "el-icon-s-home",
            path: "/dataAnalysis/angleAnalysis",
            name: "dataAnalysisAngleAnalysis",
            meta: {
              title: "浆距角分析",
            },
            component: () =>
              import("../pages/dataAnalysis/angleAnalysis/index.vue"),
          },
          {
            icon: "el-icon-s-home",
            path: "/dataAnalysis/agcAnalysis",
            name: "dataAnalysisAgcAnalysis",
            meta: {
              title: "AGC曲线偏差分析",
            },
            component: () =>
              import("../pages/dataAnalysis/agcAnalysis/index.vue"),
          },
        ],
      },
      {
        icon: "iconfont iconbaojingpeizhi",
        path: "/lightAnalysis",
        name: "lightAnalysis",
        redirect: "/lightAnalysis/glAnalysis",
        meta: {
          title: "光伏分析",
        },
        component: () => import("../pages/routerViewss.vue"),
        children: [
          {
            icon: "el-icon-s-home",
            path: "/lightAnalysis/glAnalysis",
            name: "glAnalysis",
            meta: {
              title: "功率曲线分析",
            },
            component: () =>
              import("../pages/lightAnalysis/glAnalysis/index.vue"),
          },
          {
            icon: "el-icon-s-home",
            path: "/lightAnalysis/glHotAnalysis",
            name: "glHotAnalysis",
            meta: {
              title: "功率光照曲线分析",
            },
            component: () =>
              import("../pages/lightAnalysis/glHotAnalysis/index.vue"),
          },
        ],
      },
    ],
  },

  {
    path: "/login",
    name: "Login",
    meta: {
      title: "登录",
    },
    component: () =>
      import(
        /* webpackChunkName: "login" */
        "../pages/Login.vue"
      ),
  },
  {
    path: "/check",
    name: "Check",
    meta: {
      title: "单点登录",
    },
    component: () =>
      import(
        /* webpackChunkName: "login" */
        "@/pages/check/index.vue"
      ),
  },
];

const router = createRouter({
  history: createWebHashHistory(""),
  routes,
});

router.beforeEach((to, from, next) => {
  document.title = `${to.meta.title} | 发电能力分析平台`;
  // const role = sessionStorage.getItem('ms_chinesename')
  // if (!role && to.path !== '/login') {
  //     next('/login')
  // } else {
  next();
  // }
});

export default router;
