@aniyajs/plugin-router
Version:
基于 react-routerV6 封装的路由插件服务于aniyajs自动化脚手架
47 lines (40 loc) • 1.31 kB
TypeScript
export { default as useHistory } from "./utils/history";
export { default as useParams } from "./utils/params";
export * from "react-router-dom";
export * from "./utils/common";
export interface AniyajsRouterType {
name?: string; // 路由名称
component?: React.ReactNode; // 路由组件
level?: number; // 路由层级
parentId?: string; // 父级路由id
path?: string; // 路由路径
redirect?: string; // 重定向路径
// 路由元信息
meta?: {
title?: string; // 标题
icon?: string; // 图标
};
routeType?: "1" | "2", // 路由类型,1: 菜单路由,2: 非菜单路由
routes?: AniyajsRouterType[] | [];
children?: AniyajsRouterType[] | [];
}
export interface AniyajsPluginRouterProps {
routers: AniyajsRouterType[] | [];
route: AniyajsRouterType;
children: React.ReactNode;
convertRouters: AniyajsRouterType[] | [];
};
declare module "@aniyajs/plugin-router" {
interface RouteProps {
data?: Record<string, any>;
state?: Record<string, any>;
}
interface HistoryHandle {
push: (path: string, props?: RouteProps) => void;
replace: (path: string, props?: RouteProps) => void;
go: (n: number) => void;
goBack: () => void;
}
export const useHistory: () => HistoryHandle;
export const useParams: <T>() => T;
}