2
0

perf: 路由重构

This commit is contained in:
TsMask
2024-11-29 17:09:02 +08:00
parent d7d471e552
commit a57f669603
4 changed files with 17 additions and 33 deletions

View File

@@ -36,30 +36,12 @@ declare module "@elegant-router/types" {
/**
* the first level route key, which contain the layout of the route
*/
export type FirstLevelRouteKey = Extract<
RouteKey,
| "403"
| "404"
| "500"
| "about"
| "function"
| "home"
| "login"
| "manage"
| "user"
| "user-center"
| "uui"
>;
export type FirstLevelRouteKey = string;
/**
* the custom first level route key
*/
export type CustomFirstLevelRouteKey = Extract<
CustomRouteKey,
| "root"
| "not-found"
| "exception"
>;
export type CustomFirstLevelRouteKey = string;
/**
* the last level route key, which has the page file
@@ -69,14 +51,7 @@ declare module "@elegant-router/types" {
/**
* the custom last level route key
*/
export type CustomLastLevelRouteKey = Extract<
CustomRouteKey,
| "root"
| "not-found"
| "exception_403"
| "exception_404"
| "exception_500"
>;
export type CustomLastLevelRouteKey = string;
/**
* the single level route key
@@ -123,8 +98,10 @@ declare module "@elegant-router/types" {
type SingleLevelRoute<K extends SingleLevelRouteKey = SingleLevelRouteKey> = K extends string
? Omit<ElegantConstRoute, 'children'> & {
name: K;
path: string;
component: `layout.${RouteLayout}$view.${K}`;
path: K;
meta?: Record<K, any>;
component?: `layout.${RouteLayout}$view.${K}` | `layout.${RouteLayout}` | `view.${K}` ;
children?: SingleLevelRoute[];
}
: never;
@@ -156,7 +133,7 @@ declare module "@elegant-router/types" {
type MultiLevelRoute<K extends FirstLevelRouteNotSingleKey = FirstLevelRouteNotSingleKey> = K extends string
? ElegantConstRoute & {
name: K;
path: string;
path: K;
component: `layout.${RouteLayout}`;
children: (CenterLevelRoute<GetChildRouteKey<K>> | LastLevelRoute<GetChildRouteKey<K>>)[];
}