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';

const modules = import.meta.glob('./modules/**/*.ts', { eager: true });

const routeModuleList: AppRouteModule[] = [];

// 加入到路由集合中
Object.keys(modules).forEach((key) => {
  const mod = (modules as Recordable)[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'),
  //component: () => import('/@/views/system/loginmini/MiniLogin.vue'),
  meta: {
    title: t('routes.basic.login'),
  },
};

//update-begin---author:wangshuai ---date:20220629  for：auth2登录页面路由------------
export const Oauth2LoginRoute: AppRouteRecordRaw = {
  path: '/oauth2-app/login',
  name: 'oauth2-app-login',
  //新版钉钉免登录，如果想要使用旧版放开即可
  // component: () => import('/@/views/sys/login/OAuth2Login.vue'),
  component: () => import('/@/views/system/loginmini/OAuth2Login.vue'),
  meta: {
    title: t('routes.oauth2.login'),
  },
};
//update-end---author:wangshuai ---date:20220629  for：auth2登录页面路由------------

/**
 * 【通过token直接静默登录】流程办理登录页面 中转跳转
 */
export const TokenLoginRoute: AppRouteRecordRaw = {
  path: '/tokenLogin',
  name: 'TokenLoginRoute',
  component: () => import('/@/views/sys/login/TokenLoginPage.vue'),
  meta: {
    title: '带token登录页面',
    ignoreAuth: true,
  },
};



export const ProjectRoute: AppRouteRecordRaw = {
  path: '/audit/project/ProjectItemIndexApi',
  name: 'ProjectItemIndex',
  component: () => import('/@/views/audit/project/ProjectItemIndex.vue'),
  meta: {
    title: '项目内容管理',
    
  },
};

export const ProjectTaskAssignRoute: AppRouteRecordRaw = {
  path: '/audit/project/ProjectTaskAssignIndexApi',
  name: 'ProjectTaskAssignIndex',
  component: () => import('/@/views/audit/project/ProjectTaskAssignIndex.vue'),
  meta: {
    title: '任务分配',
    
  },
};

export const ProjectReportRoute: AppRouteRecordRaw = {
  path: '/audit/project/ProjectReportIndexApi',
  name: 'ProjectReportIndex',
  component: () => import('/@/views/audit/project/ProjectReportIndex.vue'),
  meta: {
    title: '项目报告管理',
    
  },
};

export const BaosongTaskReviewListRoute: AppRouteRecordRaw = {
  path: '/baosong/review/baosongTaskReviewListApi',
  name: 'BaosongTaskReviewList',
  component: () => import('/@/views/baosong/review/BaosongTaskReviewList.vue'),
  meta: {
    title: '报送内容审批',
    
  },
};


export const StPlanManListRoute: AppRouteRecordRaw = {
  path: '/project/plan/stPlanManListApi',
  name: 'StPlanManList',
  component: () => import('/@/views/project/plan/components/StPlanManForm.vue'),
  meta: {
    title: '计划审批',
    
  },
};

export const MetricReportIndexRoute: AppRouteRecordRaw = {
  path: '/metric/metricReportIndexApi',
  name: 'MetricReportIndex',
  //component: () => import('/@/views/metric/metricReportIndex.vue'),
  component: () => import('/@/views/dashboard/firstPage/fxjc_index.vue'),
  meta: {
    title: '风险监测预警',
    
  },
};

export const WbSurveyRiskIndexRoute: AppRouteRecordRaw = {
  path: '/wb/WbSurveyRiskIndexApi',
  name: 'WbSurveyRiskIndex',
  component: () => import('/@/views/wb/WbSurveyRiskIndex.vue'),
  meta: {
    title: '外包商管理',
    
  },
};

export const AuditProblemDetailRoute: AppRouteRecordRaw = {
  path: '/newlib/AuditProblemDetailApi',
  name: 'AuditProblemDetail',
  component: () => import('/@/views/newlib/AuditProblemDetail.vue'),
  meta: {
    title: '风险评估管理',
    
  },
};

export const StProblemCheckFormRoute: AppRouteRecordRaw = {
  path: '/project/problem/StProblemCheckFormDetailApi',
  name: 'StProblemCheckFormDetailApi',
  component: () => import('/@/views/project/problemCheck/components/StProblemCheckFormDetail.vue'),
  meta: {
    title: '问题整改审核管理',
    
  },
};


// Basic routing without permission
export const basicRoutes = [LoginRoute, 
  RootRoute, ...mainOutRoutes,
   REDIRECT_ROUTE, 
   PAGE_NOT_FOUND_ROUTE, 
   TokenLoginRoute, 
   Oauth2LoginRoute,
   ProjectRoute,ProjectTaskAssignRoute,ProjectReportRoute,BaosongTaskReviewListRoute,StPlanManListRoute,MetricReportIndexRoute,WbSurveyRiskIndexRoute,AuditProblemDetailRoute,StProblemCheckFormRoute
  ];



