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',
path: '/about',
component: 'layout.base$view._builtin_about',
component: 'layout.base$view.about',
meta: {
title: 'about',
i18nKey: 'route.about',
@@ -171,7 +171,7 @@ export const generatedRoutes: GeneratedRoute[] = [
{
name: 'home',
path: '/home',
component: 'layout.base$view._builtin_home',
component: 'layout.base$view.home',
meta: {
title: '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
*/
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>>)[];
}

View File

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