umi-plugin-router-plus
Version:
一款 Umi 3 插件,为你带来类型友好的页面参数的定义、传递与获取。
30 lines (29 loc) • 891 B
TypeScript
interface IBaseRoute<T> {
path?: string;
routes?: T[];
}
/**
* 将路由表转换为只有一级。
*
* @param routes 路由表
*/
export declare function flattenRoutes<T extends IBaseRoute<T>>(routes: T[]): T[];
/**
* 遍历路由表。
*
* @param routes 路由表
* @param cb 回调
*/
export declare function walkRoutes<T extends IBaseRoute<T>, X>(routes: T[], cb: (route: T, parent: T | undefined) => X, parent?: T): X[];
/**
* 获取路由名称。
*
* - 将 `path` 去除 .html 后缀作为原始名称;
* - 对获取到的原始名称做 `PascalCase` 转换后作为基本名称,若其为空,则设为 Index;
* - 判断是否有子路由,是则将后缀设为 `Layout`;
* - 将基本名称和后缀相加作为路由名称返回。
*
* @param route 路由信息
*/
export declare function getRouteName(route: IBaseRoute<any>): string;
export {};