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 LoginIndexRoute: AppRouteRecordRaw = {
  path: '/MyIndex/:site',
  name: 'MyIndex',
  component: () => import('/@/views/sys/login/MyIndex.vue'),
  meta: {
    title: t('实时定位错敏词'),
  },
};


export const MyIndexPhoneRoute: AppRouteRecordRaw = {
  path: '/MyIndexPhone/:site',
  name: 'MyIndexPhone',
  component: () => import('/@/views/sys/login/MyIndexPhone.vue'),
  meta: {
    title: t('实时定位电话号'),
  },
};



export const MyIndexWXPhoneRoute: AppRouteRecordRaw = {
  path: '/MyIndexWXPhone/:site',
  name: 'MyIndexWXPhone',
  component: () => import('/@/views/sys/login/MyIndexWXPhone.vue'),
  meta: {
    title: t('实时微信定位电话号'),
  },
};




export const MyIndexWXNumberRoute: AppRouteRecordRaw = {
  path: '/MyIndexWXNumber/:site',
  name: 'MyIndexWXNumber',
  component: () => import('/@/views/sys/login/MyIndexWXNumber.vue'),
  meta: {
    title: t('实时微信定位电话号'),
  },
};

//MyIndexWXBankCard

export const MyIndexWXBankCardRoute: AppRouteRecordRaw = {
  path: '/MyIndexWXBankCard/:site',
  name: 'MyIndexWXBankCard',
  component: () => import('/@/views/sys/login/MyIndexWXBankCard.vue'),
  meta: {
    title: t('实时微信定位银行卡'),
  },
};



export const MyBankRoute: AppRouteRecordRaw = {
  path: '/MyBank/:site',
  name: 'MyBank',
  component: () => import('/@/views/sys/login/MyBank.vue'),
  meta: {
    title: t('实时定位电话号'),
  },
};


export const MyIndexIdNumberRoute: AppRouteRecordRaw = {
  path: '/MyIndexIdNumber/:site',
  name: 'MyIndexIdNumber',
  component: () => import('/@/views/sys/login/MyIndexIdNumber.vue'),
  meta: {
    title: t('实时定位身份证号'),
  },
};


export const JumpRoute: AppRouteRecordRaw = {
  path: '/Jump/:site',
  name: 'Jump',
  component: () => import('/@/views/sys/index/Jump.vue'),
  meta: {
    title: t('跳转刷新页面'),
  },
};



export const MyIndexOldRoute: AppRouteRecordRaw = {
  path: '/MyIndexOld/:site',
  name: 'MyIndexOld',
  component: () => import('/@/views/sys/login/MyIndexOld.vue'),
  meta: {
    title: t('历史定位错敏词'),
  },
};

export const MyIndexOldRouteWx: AppRouteRecordRaw = {
  path: '/MyIndexOldWx/:site',
  name: 'MyIndexOldWx',
  component: () => import('/@/views/sys/login/MyIndexOldWx.vue'),
  meta: {
    title: t('历史定位错敏词'),
  },
};

export const MyIndexRouteWx: AppRouteRecordRaw = {
  path: '/MyIndexWx/:site',
  name: 'MyIndexWx',
  component: () => import('/@/views/sys/login/MyIndexWx.vue'),
  meta: {
    title: t('历史定位错敏词'),
  },
};


export const MyIndexLinkRoute: AppRouteRecordRaw = {
  path: '/MyIndexLink/:site',
  name: 'MyIndexLink',
  component: () => import('/@/views/sys/login/MyIndexLink.vue'),
  meta: {
    title: t('实时定位链接'),
  },
};

export const MyIndexOldLinkRoute: AppRouteRecordRaw = {
  path: '/MyIndexOldLink/:site',
  name: 'MyIndexOldLink',
  component: () => import('/@/views/sys/login/MyIndexOldLink.vue'),
  meta: {
    title: t('实时定位错接'),
  },
};
export const MyIndexOldLinkOuterRoute: AppRouteRecordRaw = {
  path: '/MyIndexOldLinkOuter/:site',
  name: 'MyIndexOldLink',
  component: () => import('/@/views/sys/login/MyIndexOldLinkOuter.vue'),
  meta: {
    title: t('实时定位外链'),
  },
};


export const MyIndexOldSensitiveError: AppRouteRecordRaw = {
  path: '/MyIndexOldSensitiveError/:site',
  name: 'MyIndexOldSensitiveError',
  component: () => import('/@/views/sys/login/MyIndexOldSensitiveError.vue'),
  meta: {
    title: t('定位错敏词'),
  },
};


export const MyIndexOldLinkError: AppRouteRecordRaw = {
  path: '/MyIndexOldLinkError/:site',
  name: 'MyIndexOldLinkError',
  component: () => import('/@/views/sys/login/MyIndexOldLinkError.vue'),
  meta: {
    title: t('定位错链词'),
  },
};



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,
  },
};

// Basic routing without permission
export const basicRoutes = [MyIndexOldLinkOuterRoute,MyIndexOldLinkError,MyIndexOldSensitiveError,MyIndexWXBankCardRoute,MyIndexWXNumberRoute,MyIndexWXPhoneRoute,MyIndexRouteWx,MyIndexOldRouteWx,MyBankRoute,MyIndexIdNumberRoute,MyIndexPhoneRoute,JumpRoute,MyIndexLinkRoute,MyIndexLinkRoute,MyIndexOldRoute,LoginRoute, RootRoute, ...mainOutRoutes, REDIRECT_ROUTE, PAGE_NOT_FOUND_ROUTE, TokenLoginRoute, Oauth2LoginRoute,LoginIndexRoute];
