perf: 路由重构
This commit is contained in:
107
src/typings/elegant-router.d.ts
vendored
107
src/typings/elegant-router.d.ts
vendored
@@ -11,70 +11,26 @@ declare module "@elegant-router/types" {
|
||||
*/
|
||||
export type RouteLayout = "base" | "blank";
|
||||
|
||||
/**
|
||||
* route map
|
||||
*/
|
||||
export type RouteMap = {
|
||||
"root": "/";
|
||||
"not-found": "/:pathMatch(.*)*";
|
||||
"exception": "/exception";
|
||||
"exception_403": "/exception/403";
|
||||
"exception_404": "/exception/404";
|
||||
"exception_500": "/exception/500";
|
||||
"403": "/403";
|
||||
"404": "/404";
|
||||
"500": "/500";
|
||||
"about": "/about";
|
||||
"function": "/function";
|
||||
"function_hide-child": "/function/hide-child";
|
||||
"function_hide-child_one": "/function/hide-child/one";
|
||||
"function_hide-child_three": "/function/hide-child/three";
|
||||
"function_hide-child_two": "/function/hide-child/two";
|
||||
"function_multi-tab": "/function/multi-tab";
|
||||
"function_request": "/function/request";
|
||||
"function_super-page": "/function/super-page";
|
||||
"function_tab": "/function/tab";
|
||||
"function_toggle-auth": "/function/toggle-auth";
|
||||
"home": "/home";
|
||||
"login": "/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?";
|
||||
"manage": "/manage";
|
||||
"manage_dept": "/manage/dept";
|
||||
"manage_dict": "/manage/dict";
|
||||
"manage_menu": "/manage/menu";
|
||||
"manage_post": "/manage/post";
|
||||
"manage_role": "/manage/role";
|
||||
"manage_route": "/manage/route";
|
||||
"manage_user": "/manage/user";
|
||||
"manage_user-detail": "/manage/user-detail/:id";
|
||||
"user-center": "/user-center";
|
||||
};
|
||||
|
||||
/**
|
||||
* route key
|
||||
*/
|
||||
export type RouteKey = keyof RouteMap;
|
||||
export type RouteKey = string;
|
||||
|
||||
/**
|
||||
* route path
|
||||
*/
|
||||
export type RoutePath = RouteMap[RouteKey];
|
||||
export type RoutePath = string;
|
||||
export type RouteMap =Record<string,string>;
|
||||
|
||||
/**
|
||||
* custom route key
|
||||
*/
|
||||
export type CustomRouteKey = Extract<
|
||||
RouteKey,
|
||||
| "root"
|
||||
| "not-found"
|
||||
| "exception"
|
||||
| "exception_403"
|
||||
| "exception_404"
|
||||
| "exception_500"
|
||||
>;
|
||||
*/
|
||||
export type CustomRouteKey = string;
|
||||
|
||||
/**
|
||||
* the generated route key
|
||||
*/
|
||||
*/
|
||||
export type GeneratedRouteKey = Exclude<RouteKey, CustomRouteKey>;
|
||||
|
||||
/**
|
||||
@@ -90,7 +46,9 @@ declare module "@elegant-router/types" {
|
||||
| "home"
|
||||
| "login"
|
||||
| "manage"
|
||||
| "user"
|
||||
| "user-center"
|
||||
| "uui"
|
||||
>;
|
||||
|
||||
/**
|
||||
@@ -106,32 +64,7 @@ declare module "@elegant-router/types" {
|
||||
/**
|
||||
* the last level route key, which has the page file
|
||||
*/
|
||||
export type LastLevelRouteKey = Extract<
|
||||
RouteKey,
|
||||
| "403"
|
||||
| "404"
|
||||
| "500"
|
||||
| "login"
|
||||
| "about"
|
||||
| "function_hide-child_one"
|
||||
| "function_hide-child_three"
|
||||
| "function_hide-child_two"
|
||||
| "function_multi-tab"
|
||||
| "function_request"
|
||||
| "function_super-page"
|
||||
| "function_tab"
|
||||
| "function_toggle-auth"
|
||||
| "home"
|
||||
| "manage_dept"
|
||||
| "manage_dict"
|
||||
| "manage_menu"
|
||||
| "manage_post"
|
||||
| "manage_role"
|
||||
| "manage_route"
|
||||
| "manage_user-detail"
|
||||
| "manage_user"
|
||||
| "user-center"
|
||||
>;
|
||||
export type LastLevelRouteKey = string
|
||||
|
||||
/**
|
||||
* the custom last level route key
|
||||
@@ -190,7 +123,7 @@ declare module "@elegant-router/types" {
|
||||
type SingleLevelRoute<K extends SingleLevelRouteKey = SingleLevelRouteKey> = K extends string
|
||||
? Omit<ElegantConstRoute, 'children'> & {
|
||||
name: K;
|
||||
path: RouteMap[K];
|
||||
path: string;
|
||||
component: `layout.${RouteLayout}$view.${K}`;
|
||||
}
|
||||
: never;
|
||||
@@ -201,18 +134,18 @@ declare module "@elegant-router/types" {
|
||||
type LastLevelRoute<K extends GeneratedRouteKey> = K extends LastLevelRouteKey
|
||||
? Omit<ElegantConstRoute, 'children'> & {
|
||||
name: K;
|
||||
path: RouteMap[K];
|
||||
path: string;
|
||||
component: `view.${K}`;
|
||||
}
|
||||
: never;
|
||||
|
||||
|
||||
/**
|
||||
* the center level route
|
||||
*/
|
||||
type CenterLevelRoute<K extends GeneratedRouteKey> = K extends CenterLevelRouteKey
|
||||
? Omit<ElegantConstRoute, 'component'> & {
|
||||
name: K;
|
||||
path: RouteMap[K];
|
||||
path: string;
|
||||
children: (CenterLevelRoute<GetChildRouteKey<K>> | LastLevelRoute<GetChildRouteKey<K>>)[];
|
||||
}
|
||||
: never;
|
||||
@@ -223,19 +156,19 @@ declare module "@elegant-router/types" {
|
||||
type MultiLevelRoute<K extends FirstLevelRouteNotSingleKey = FirstLevelRouteNotSingleKey> = K extends string
|
||||
? ElegantConstRoute & {
|
||||
name: K;
|
||||
path: RouteMap[K];
|
||||
path: string;
|
||||
component: `layout.${RouteLayout}`;
|
||||
children: (CenterLevelRoute<GetChildRouteKey<K>> | LastLevelRoute<GetChildRouteKey<K>>)[];
|
||||
}
|
||||
: never;
|
||||
|
||||
|
||||
/**
|
||||
* the custom first level route
|
||||
*/
|
||||
type CustomSingleLevelRoute<K extends CustomFirstLevelRouteKey = CustomFirstLevelRouteKey> = K extends string
|
||||
? Omit<ElegantConstRoute, 'children'> & {
|
||||
name: K;
|
||||
path: RouteMap[K];
|
||||
path: string;
|
||||
component?: `layout.${RouteLayout}$view.${LastLevelRouteKey}`;
|
||||
}
|
||||
: never;
|
||||
@@ -246,7 +179,7 @@ declare module "@elegant-router/types" {
|
||||
type CustomLastLevelRoute<K extends CustomRouteKey> = K extends CustomLastLevelRouteKey
|
||||
? Omit<ElegantConstRoute, 'children'> & {
|
||||
name: K;
|
||||
path: RouteMap[K];
|
||||
path: string;
|
||||
component?: `view.${LastLevelRouteKey}`;
|
||||
}
|
||||
: never;
|
||||
@@ -257,7 +190,7 @@ declare module "@elegant-router/types" {
|
||||
type CustomCenterLevelRoute<K extends CustomRouteKey> = K extends CustomCenterLevelRouteKey
|
||||
? Omit<ElegantConstRoute, 'component'> & {
|
||||
name: K;
|
||||
path: RouteMap[K];
|
||||
path: string;
|
||||
children: (CustomCenterLevelRoute<GetChildRouteKey<K>> | CustomLastLevelRoute<GetChildRouteKey<K>>)[];
|
||||
}
|
||||
: never;
|
||||
@@ -269,7 +202,7 @@ declare module "@elegant-router/types" {
|
||||
K extends string
|
||||
? ElegantConstRoute & {
|
||||
name: K;
|
||||
path: RouteMap[K];
|
||||
path: string;
|
||||
component: `layout.${RouteLayout}`;
|
||||
children: (CustomCenterLevelRoute<GetChildRouteKey<K>> | CustomLastLevelRoute<GetChildRouteKey<K>>)[];
|
||||
}
|
||||
@@ -278,7 +211,7 @@ declare module "@elegant-router/types" {
|
||||
/**
|
||||
* the custom route
|
||||
*/
|
||||
type CustomRoute = CustomSingleLevelRoute | CustomMultiLevelRoute;
|
||||
type CustomRoute = CustomSingleLevelRoute | CustomMultiLevelRoute | any;
|
||||
|
||||
/**
|
||||
* the generated route
|
||||
|
||||
Reference in New Issue
Block a user