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

@@ -42,7 +42,7 @@ export const generatedRoutes: GeneratedRoute[] = [
{ {
name: 'about', name: 'about',
path: '/about', path: '/about',
component: 'layout.base$view._builtin_about', component: 'layout.base$view.about',
meta: { meta: {
title: 'about', title: 'about',
i18nKey: 'route.about', i18nKey: 'route.about',
@@ -171,7 +171,7 @@ export const generatedRoutes: GeneratedRoute[] = [
{ {
name: 'home', name: 'home',
path: '/home', path: '/home',
component: 'layout.base$view._builtin_home', component: 'layout.base$view.home',
meta: { meta: {
title: 'home', title: 'home',
i18nKey: 'route.home', i18nKey: 'route.home',

View File

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

View File

@@ -0,0 +1,7 @@
<script setup lang="ts"></script>
<template>
<div>user_vip</div>
</template>
<style scoped></style>