import { ReactNode, ComponentType, ElementType } from 'react'; import { RouteProps } from 'react-router-dom'; export interface RouteBaseConfig = {}, Auth = number> extends Omit { path?: string; /** 重定向地址 */ redirectTo?: string; /** 组件所在的目录,默认为路由的path */ catalog?: string; /** 进入路由的权限 */ auth?: Auth; /** 是否使用布局,默认 true */ useLayout?: boolean; /** 子路由配置 */ children?: RouteConfig[]; /** 加载中或失败时的内容 */ fallback?: ReactNode; /** 无权限时展示的内容 */ noAuthDisplay?: ReactNode; /** 有子路由时,自身是否为路由,默认 false */ exist?: boolean; } export type RouteConfig = {}, Auth = number> = RouteBaseConfig & Extend; export type Routes = {}, Auth = number> = RouteConfig[]; export type HighOrderRoute = {}, Auth = number> = RouteConfig | Array>; export type CheckAuth = {}, Auth = number> = (config: RouteConfig) => boolean; export interface CosmosRouterProps = {}, Auth = number> { /** 路由配置项数组 */ routes: Routes; /** 默认的路由配置 */ defaultConfig?: RouteConfig; /** 懒加载时引用组件的方法 */ lazyLoad?: (path: string) => Promise<{ default: ComponentType; }>; /** 路由的布局组件 */ layout?: ElementType; /** 校验权限的方法 */ checkAuth?: CheckAuth; /** 校验结果是否已返回 */ hasCheckResult?: boolean; /** 文件目录结构是否跟随路由结构,默认 false */ catalogFromRoute?: boolean; };