import type { AppRouteRecordRaw, AppRouteModule } from '/@/router/types';
import { PAGE_NOT_FOUND_ROUTE, REDIRECT_ROUTE } from '/@/router/routes/basic';
import { mainOutRoutes } from './mainOut';
import { PageEnum } from '/@/enums/pageEnum';
import { t } from '/@/hooks/web/useI18n';
import { LAYOUT } from '../constant';

const modules = import.meta.globEager('./modules/**/*.ts');
const routeModuleList: AppRouteModule[] = [];
Object.keys(modules).forEach((key) => {
  const mod = modules[key].default || {};
  const modList = Array.isArray(mod) ? [...mod] : [mod];
  routeModuleList.push(...modList);
});

export const asyncRoutes = [PAGE_NOT_FOUND_ROUTE, ...routeModuleList];
export const RootRoute: AppRouteRecordRaw = {
  path: '/',
  name: 'Root',
  redirect: PageEnum.BASE_HOME,
  meta: {
    title: 'Root',
  },
};

export const LoginRoute: AppRouteRecordRaw = {
  path: '/login',
  name: 'Login',
  component: () => import('/@/views/sys/login/Login.vue'),
  meta: {
    title: t('routes.basic.login'),
  },
};

//import Home from '../../views/home/Home.vue';
// 气象页面
import weatherHome from '../../views/weatherHome/Home.vue';
// import Product from '../../views/product/Product.vue';
// 水文页面
import hydrology from '../../views/hydrology/index.vue';
// import Building from '../../views/building/Building.vue';
// 气象页面
import meteorological from '../../views/meteorological/index.vue';
// import warning from '../../views/warning/warning.vue';
// 预报信息
import prediction from '../../views/prediction/index.vue';
//大屏路由地址
export const ScreenRoutes: AppRouteRecordRaw = {
  path: '/system2',
  name: '系统管理',
  component: () => import('/@/views/screen/index.vue'),
  meta: {
    title: '系统管理',
    hideBreadcrumb: true,
    hideChildrenInMenu: true,
  },
  children: [
    // {
    //   path: '/home',
    //   name: 'Home',
    //   meta: {
    //     title: '系统概览',
    //     screen: true,
    //   },
    //   component: Home,
    // },
    {
      path: '/home',
      name: 'Home',
      meta: {
        title: '综合信息',
        screen: true,
      },
      component: weatherHome,
    },
    {
      path: '/product',
      name: 'Product',
      meta: {
        title: '水文信息',
        screen: true,
      },
      component: hydrology,
    },
    {
      path: '/building',
      name: 'Building',
      meta: {
        title: '气象信息',
        screen: true,
      },
      component: meteorological,
    },
    {
      path: '/warning',
      name: 'warning',
      meta: {
        title: '预报信息',
        screen: true,
      },
      component: prediction,
    },
  ],
};

// 调度日志静态路由
export const SchedueLog: AppRouteRecordRaw = {
  path: '/report',
  name: '报表管理',
  component: LAYOUT,
  meta: {
    title: '报表管理',
    hideBreadcrumb: true,
    hideChildrenInMenu: true,
  },
  children: [
    {
      path: 'schedue_log/:id',
      name: 'Schedue_Log',
      // component: () => import('../../views/system/scheduled/SchedueLog.vue'),
      meta: {
        title: '调度日志',
      },
    },
  ],
};
// Basic routing without permission
export const basicRoutes = [LoginRoute, RootRoute, ScreenRoutes, SchedueLog, ...mainOutRoutes, REDIRECT_ROUTE, PAGE_NOT_FOUND_ROUTE];
