import { createRouter, Router, createWebHashHistory, createWebHistory, RouteRecordRaw } from 'vue-router'

const Home: any = () => import('@/views/home/index.vue')
const Envmonitor: any = () => import('@/views/envmonitor/index.vue')
const EnvmonitorDetail: any = () => import('@/views/envmonitor/detail.vue')
const UserPortrait: any = () => import('@/views/portrait/index.vue')
const EnergySavig: any = () => import('@/views/portrait/energySavig.vue')
const EnergyDetail: any = () => import('@/views/portrait/energyDetail.vue')
const TodayEnergyDetail: any = () => import('@/views/portrait/todayEnergyDetail.vue')
const EnergyRank: any = () => import('@/views/portrait/energyRank.vue')
const IntegralDesc: any = () => import('@/views/portrait/integralDesc.vue')
const Record: any = () => import('@/views/portrait/record.vue')
const MySpace: any = () => import('@/views/envmonitor/mySpace/index.vue')
const SetMainSpace: any = () => import('@/views/choiceSpace/setMainSpace.vue')

// 吉宝静安中心入口屏幕
const EntranceScreen: any = () => import('@/views/pac/entranceScreen.vue')

export const constantRoutes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/home',
    meta: {
      title: '首页',
      hideHeader: true
    }
  },
  {
    path: '/home',
    component: Home,
    name: 'home',
    meta: {
      title: '首页',
      hideHeader: true
    }
  },
  {
    path: '/envmonitor',
    component: Envmonitor,
    // component: resolve => require(['@/views/envmonitor/index.vue'], resolve),
    name: 'envmonitor',
    meta: {
      title: '环境控制',
      hideHeader: true
    }
  },
  {
    path: '/envmonitor-detail',
    // component: () => import('@/views/envmonitor/detail.vue'),
    component: EnvmonitorDetail,
    name: 'envmonitorDetail',
    meta: {
      title: '环境详情',
      color: '#fff',
      hideHeader: true
    }
  },
  {
    path: '/user-portrait',
    // component: () => import('@/views/portrait/index.vue'),
    component: UserPortrait,
    name: 'userPortrait',
    meta: {
      title: '节能评分',
      color: '#FFE823',
      hideHeader: true
    }
  },
  {
    path: '/energy-savig',
    // component: () => import('@/views/portrait/energySavig.vue'),
    component: EnergySavig,
    name: 'energySavig',
    meta: {
      title: '我的节能',
      color: '#ECEFF4',
      hideHeader: true
    }
  },
  {
    path: '/energy-detail',
    // component: () => import('@/views/portrait/energyDetail.vue'),
    component: EnergyDetail,
    name: 'energyDetail',
    meta: {
      title: '我的节能详情 ',
      color: '#E5E5E5',
      hideHeader: true
    }
  },
  {
    path: '/today-energy-detail',
    // component: () => import('@/views/portrait/todayEnergyDetail.vue'),
    component: TodayEnergyDetail,
    name: 'todayEnergyDetail',
    meta: {
      title: '今天新增 ',
      color: '#E5E5E5',
      hideHeader: true
    }
  },
  {
    path: '/energy-rank',
    // component: () => import('@/views/portrait/energyRank.vue'),
    component: EnergyRank,
    name: 'energyRank',
    meta: {
      title: '节能排名 ',
      color: '#E5E5E5',
      hideHeader: true
    }
  },
  {
    path: '/integral-desc',
    // component: () => import('@/views/portrait/integralDesc.vue'),
    component: IntegralDesc,
    name: 'integralDesc',
    meta: {
      title: '积分说明 ',
      color: '#E5E5E5',
      hideHeader: true
    }
  },
  {
    path: '/record',
    // component: () => import('@/views/portrait/record.vue'),
    component: Record,
    name: 'Record',
    meta: {
      title: '调节记录 ',
      color: '#E5E5E5',
      hideHeader: true
    }
  },
  {
    path: '/mySpace',
    // component: () => import('@/views/envmonitor/mySpace/index.vue'),
    component: MySpace,
    name: 'mySpace',
    meta: {
      title: '切换空间',
      color: '#f7f8fa',
      hideHeader: true
    }
  },
  {
    path: '/choice-project',
    component: () => import('@/views/choiceSpace/choiceProject.vue'),
    name: 'choiceProject',
    meta: {
      title: '选择所属公司名称',
      toName: "home",
      color: '#fff',
      hideHeader: false,
      showLogoOut: true
    }
  },
  {
    path: '/choice-space',
    component: () => import('@/views/choiceSpace/choiceSpace.vue'),
    name: 'choiceSpace',
    meta: {
      title: '选择办公空间',
      // toName: "choiceProject",
      color: '#F5F5F5',
      hideHeader: false
    }
  },
  {
    path: '/set-main-space',
    component: SetMainSpace,
    name: 'setMainSpace',
    meta: {
      title: '设置主空间',
      title1: '左滑动可删除空间',
      color: '#F5F5F5',
      hideHeader: false
    }
  },
  // {
  //   path: '/map-data',
  //   component: () => import('@/views/mapData/index.vue'),
  //   name: 'mapData',
  //   meta: {
  //     title: '处理地图数据',
  //     color: '#F5F5F5',
  //     hideHeader: false
  //   }
  // },
  {
    path: '/map-data-util',
    component: () => import('@/views/mapData/indexOld.vue'),
    name: 'mapDataold',
    meta: {
      title: '处理地图数据',
      color: '#F5F5F5',
      hideHeader: false
    }
  },
  // {
  //   path: '/map-data-new',
  //   component: () => import('@/views/mapDataNew/index.vue'),
  //   name: 'mapDataNew',
  //   meta: {
  //     title: '地图数据处理',
  //     color: '#F5F5F5',
  //     hideHeader: false
  //   }
  // },
  // {
  //   path: '/map-sichuan',
  //   component: () => import('@/views/mapDataNew/sichuan.vue'),
  //   name: 'map-sichuan',
  //   meta: {
  //     title: '四川大厦地图',
  //     color: '#F5F5F5',
  //     hideHeader: false
  //   }
  // },
  {
    path: '/error',
    component: () => import('@/views/error/index.vue'),
    name: 'error',
    meta: {
      title: '错误页面',
      color: '#F5F5F5',
      hideHeader: true
    }
  },
  {
    path: '/entrance-screen',
    component: EntranceScreen,
    meta: {
      title: '入口',
      hideHeader: true
    }
  }
]

export const asyncRoutes: Array<RouteRecordRaw> = [
  // ...permissionModules
]
const router = createRouter({
  history: createWebHistory('/sgipad/'),
  routes: constantRoutes
})

export function resetRouter() {
  const newRouter = router;
  (router as any).matcher = (newRouter as any).matcher // reset router
}

export default router
