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


/**
 * Note: 路由配置项
 *
 * hidden: true                     // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true                 // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                  // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                  // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                  // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect             // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'               // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
 * roles: ['admin', 'common']       // 访问路由的角色权限
 * permissions: ['a:a:a', 'b:b:b']  // 访问路由的菜单权限
 * meta : {
    noCache: true                   // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'                  // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'                // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false               // 如果设置为false，则不会在breadcrumb面包屑中显示
    activeMenu: '/system/user'      // 当路由设置了该属性，则会高亮相对应的侧边栏。
  }
 */
// 公共路由
export const constantRoutes = [
 {
    path: '',
    component: ()=>import("@/layout/index.vue"), // 确保组件名匹配
    children: [
      {
        path: '',
        name: 'index',
        component: () => import('@/pages/all/index.vue'),
        // meta: { keepAlive: true }, // 添加keepAlive元信息
        children: [
          {
              path: '',
              name: 'home',
              // 如果需要命名视图
              components: {
                foot_two: ()=> import('@/pages/footer/component/legend.vue'), // 主内容
                foot_one: ()=> import('@/pages/footer/component/timers.vue'),
                left:()=> import('@/pages/lefts/index.vue'),
                right:()=> import('@/pages/rights/index.vue'),
              }
          },
          {
             path: '/subsystem',
              name: 'subsystem',
              props: true,
              // meta: {
              //   startTime: useAppStoreInstance.globalSubsystemSelectedStartTime,
              //   endTime: useAppStoreInstance.globalSubsystemSelectedEndTime,
              //   disabled:true
              // },
              components: {
                // foot_two: ()=> import('@/pages/footer/component/legend.vue'), // 主内容
                foot_two: ()=> import('@/pages/footer2/timers.vue'),
                left:()=> import('@/pages/lefts2/index.vue'),
                right:()=> import('@/pages/rights2/index.vue'),
              }
          },
        ]
      },
    ]
  },
     
      
    
  
   {
        path: '/404',
        component: () => import('@/pages/error/404.vue'),
        hidden: true
      },
  // // {
  // //   path: '/redirect',
  // //   component: Layout,
  // //   hidden: true,
  // //   children: [
  // //     {
  // //       path: '/redirect/:path(.*)',
  // //       component: () => import('@/views/redirect/index.vue')
  // //     }
  // //   ]
  // // },
  {
    // path: '/login',
    // component: () => import('../views/login/index1.vue'),
    // component: () => import('@/layout/index.vue'),
    // component: () => import('@/views/login/index.vue'),
    // hidden: true,
  //   children: [
  //     {
  //       path: '/index1',
  //       components: {
  //         default:test,
  //         foot_two: test
  //       },
  //     },
  //   ],
   
  },
  // {
  //   path: "/:pathMatch(.*)*",
  //   component: () => import('@/views/error/404.vue'),
  //   hidden: true
  // },
  // {
  //   path: '/401',
  //   component: () => import('@/views/error/401.vue'),
  //   hidden: true
  // },

  // {
  //   path: '',
  //   component: Layout,
  //   // redirect: '/home',
  //   // hidden: true,//注释平台首页
  //   children: [
  //     {
  //       path: '/home',
  //       component: () => import('../views/home/index.vue'),
  //       name: 'Home',
  //       meta: { title: '工作台', icon: 'dashboard', affix: true },
  //     },
  //     {
  //       path: '/buildManage',
  //       component: () => import('../views/buildManage/index.vue'),
  //       name: 'BuildManage',
  //       meta: { title: '建筑管理', icon: 'dashboard', affix: true },

  //     },
  //     {
  //       path: '/uavManage',
  //       component: () => import('../views/uavManage/index.vue'),
  //       name: 'UavManage',
  //       meta: { title: '无人机管理', icon: 'dashboard', affix: true }
  //     },
  //     {
  //       path: '/fireManage',
  //       component: () => import('../views/fireManage/index.vue'),
  //       name: 'FireManage',
  //       meta: { title: '火情管理', icon: 'dashboard', affix: true },
  //       props: true
  //     },
  //     {
  //       path: '/fileHistory',
  //       component: () => import('../views/fileHistory/index.vue'),
  //       name: 'FileHistory',
  //       meta: { title: '历史火情', icon: 'dashboard', affix: true }
  //     },
  //     {
  //       path: '/staffManage',
  //       component: () => import('../views/staffManage/index.vue'),
  //       name: 'StaffManage',
  //       meta: { title: '人员管理', icon: 'dashboard', affix: true }
  //     },
  //     {
  //       path: '/dashboard/analysis',
  //       component: () => import('../views/dashboard/analysis/index.vue'),
  //       name: 'analySisPage',
  //       meta: { title: '分析页面', icon: 'dashboard', affix: true }
  //     },
  //     {
  //       path: '/dashboard/workbench',
  //       component: () => import('../views/dashboard/workbench/index.vue'),
  //       name: 'WorkbenchPage',
  //       meta: { title: '工作台', icon: 'dashboard', affix: true }
  //     },
  //     {
  //       path: '/systemmanage/staffManage',
  //       component: () => import('../views/systemmanage/staffManage/index.vue'),
  //       name: 'systemManage',
  //       meta: { title: '人员管理', icon: 'dashboard', affix: true }
  //     },
  //     {
  //       path: '/areabuildmanage',
  //       component: () => import('../views/areabuildmanage/index.vue'),
  //       name: 'areaBuildmanage',
  //       meta: { title: '建筑管理', icon: 'dashboard', affix: true }
  //     },
  //     {
  //       path: '/uavshowdate',
  //       component: () => import('../views/uavshowdate/index.vue'),
  //       name: 'uavShowdate',
  //       meta: { title: '无人机调度', icon: 'dashboard', affix: true }
  //     },
  //     {
  //       path: '/areafiremanage/firesurveillance',
  //       component: () => import('../views/areafiremanage/firesurveillance/index.vue'),
  //       name: 'fireSurveillance',
  //       meta: { title: '历史火情', icon: 'dashboard', affix: true }
  //     },
  //     {
  //       path: '/areafiremanage/historyfire',
  //       component: () => import('../views/areafiremanage/historyfire/index.vue'),
  //       name: 'historyFire',
  //       meta: { title: '当前火情', icon: 'dashboard', affix: true },

  //     },
  //     {
  //       path: '/floordetail',
  //       component: () => import('../views/areafiremanage/historyfire/components/floordetail.vue'),
  //       name: 'floorDetail',
  //       meta: { title: '详细楼层火情', icon: 'dashboard', affix: true }
  //     },
  //     {
  //       path: '/showdetaildate',
  //       component: () => import('../views/areabuildmanage/components/showdetaildate.vue'),
  //       name: 'showDetaildate',
  //       meta: { title: '楼详细建筑数据', icon: 'dashboard', affix: true }
  //     },
  //     {
  //       path: '/areabuildmanage/onefloor',
  //       component: () => import('../views/areabuildmanage/onefloor/index.vue'),
  //       name: 'oneFloorBuildingDetailDate',
  //       meta: { title: '层详细建筑数据', icon: 'dashboard', affix: true }
  //     },
  //     {
  //       path: '/uavshowdate/uavmanage',
  //       component: () => import('../views/uavshowdate/uavmanage/index.vue'),
  //       name: 'uavDetailDate',
  //       meta: { title: '无人机管理', icon: 'dashboard', affix: true }
  //     },

  //     {
  //       path: '/areafiremanage/firerecord',
  //       component: () => import('../views/areafiremanage/firerecord/index.vue'),
  //       name: 'recordFireInfo',
  //       meta: { title: '火情记录管理', icon: 'dashboard', affix: true }
  //     },


  //   ]
  // },

]

const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { top: 0 }
    }
  },
});

export default router;
