UNPKG

2.31 kBTypeScriptView Raw
1import type * as H from 'history';
2import type React from 'react';
3export interface StaticContext {
4 statusCode?: number | undefined;
5}
6export interface BasicRouteProps<Params extends {
7 [K in keyof Params]?: string;
8} = Record<string, any>, C extends StaticContext = StaticContext, S = H.LocationState> {
9 history: H.History<S>;
10 location: H.Location<S>;
11 match: match<Params>;
12 staticContext?: C | undefined;
13}
14export interface match<Params extends {
15 [K in keyof Params]?: string;
16} = Record<string, any>> {
17 params: Params;
18 isExact: boolean;
19 path: string;
20 url: string;
21}
22export type LinkProps = {
23 to: H.LocationDescriptor;
24 replace?: boolean;
25 innerRef?: React.Ref<HTMLAnchorElement>;
26} & React.AnchorHTMLAttributes<HTMLAnchorElement>;
27export type MenuDataItem = {
28 /** @name 子菜单 */
29 children?: MenuDataItem[];
30 routes?: undefined;
31 /** @name 在菜单中隐藏子节点 */
32 hideChildrenInMenu?: boolean;
33 /** @name 在菜单中隐藏自己和子节点 */
34 hideInMenu?: boolean;
35 /** @name 菜单的icon */
36 icon?: React.ReactNode;
37 /** @name 自定义菜单的国际化 key */
38 locale?: string | false;
39 /** @name 菜单的名字 */
40 name?: string;
41 /** @name 用于标定选中的值,默认是 path */
42 key?: string;
43 /** @name disable 菜单选项 */
44 disabled?: boolean;
45 /** @name 路径,可以设定为网页链接 */
46 path?: string;
47 /**
48 * 当此节点被选中的时候也会选中 parentKeys 的节点
49 *
50 * @name 自定义父节点
51 */
52 parentKeys?: string[];
53 /** @name 隐藏自己,并且将子节点提升到与自己平级 */
54 flatMenu?: boolean;
55 /** @name 指定外链打开形式,同a标签 */
56 target?: string;
57 /**
58 * menuItem 的 tooltip 显示的路径
59 */
60 tooltip?: string;
61 [key: string]: any;
62};
63export type Route = Omit<MenuDataItem, 'routes'> & {
64 children?: Route[];
65};
66export type WithFalse<T> = T | false;
67export type RouterTypes = {
68 computedMatch?: match<any>;
69 route?: Route;
70 location: BasicRouteProps['location'] | {
71 pathname?: string;
72 };
73} & Omit<BasicRouteProps, 'location'>;
74export type MessageDescriptor = {
75 id: any;
76 description?: string;
77 defaultMessage?: string;
78};