Skip to content

Commit

Permalink
perf(projects): perf config
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Oct 18, 2023
1 parent bd4ebdf commit 6a474af
Show file tree
Hide file tree
Showing 16 changed files with 92 additions and 96 deletions.
14 changes: 7 additions & 7 deletions examples/template-vue/src/router/elegant/imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ export const layouts: Record<RouteLayout, RouteComponent | (() => Promise<RouteC
};

export const views: Record<LastLevelRouteKey, RouteComponent | (() => Promise<RouteComponent>)> = {
403: () => import("@/views/403/index.vue"),
404: () => import("@/views/404/index.vue"),
500: () => import("@/views/500/index.vue"),
"demo-a_child1": () => import("@/views/demo-a/child1/index.vue"),
"demo-a_child2_child3": () => import("@/views/demo-a/child2/child3/index.vue"),
"demo-a_child3": () => import("@/views/demo-a/child3/index.vue"),
demo3: () => import("@/views/demo3/[id].vue"),
403: () => import("@/views/_error/403/index.vue"),
404: () => import("@/views/_error/404/index.vue"),
500: () => import("@/views/_error/500/index.vue"),
about: () => import("@/views/about/index.vue"),
list_detail: () => import("@/views/list/detail/index.vue"),
list_home: () => import("@/views/list/home/index.vue"),
"multi-menu_first_child": () => import("@/views/multi-menu/first_child/index.vue"),
"multi-menu_second_child_home": () => import("@/views/multi-menu/second_child_home/index.vue"),
user: () => import("@/views/user/[id].vue"),
};
82 changes: 39 additions & 43 deletions examples/template-vue/src/router/elegant/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,62 +47,44 @@ export const autoRoutes: ElegantRoute[] = [
]
},
{
name: 'demo-a',
path: '/demo-a',
path: '/about',
component: 'layout.base',
redirect: {
name: 'demo-a_child1'
},
meta: {
title: 'demo-a'
},
children: [
{
name: 'demo-a_child1',
path: '/demo-a/child1',
component: 'view.demo-a_child1',
meta: {
title: 'demo-a_child1'
}
},
{
name: 'demo-a_child2',
path: '/demo-a/child2',
redirect: {
name: 'demo-a_child2_child3'
},
meta: {
title: 'demo-a_child2'
}
},
{
name: 'demo-a_child2_child3',
path: '/demo-a/child2/child3',
component: 'view.demo-a_child2_child3',
meta: {
title: 'demo-a_child2_child3'
}
},
{
name: 'demo-a_child3',
path: '/demo-a/child3',
component: 'view.demo-a_child3',
name: 'about',
path: '',
component: 'view.about',
meta: {
title: 'demo-a_child3'
title: 'about'
}
}
]
},
{
path: '/demo3/:id',
name: 'list',
path: '/list',
component: 'layout.base',
redirect: {
name: 'list_detail'
},
meta: {
title: 'list'
},
children: [
{
name: 'demo3',
path: '',
component: 'view.demo3',
name: 'list_detail',
path: '/list/detail',
component: 'view.list_detail',
meta: {
title: 'demo3'
title: 'list_detail'
}
},
{
name: 'list_home',
path: '/list/home',
component: 'view.list_home',
meta: {
title: 'list_home'
}
}
]
Expand Down Expand Up @@ -165,5 +147,19 @@ export const autoRoutes: ElegantRoute[] = [
}
}
]
},
{
path: '/user/:id',
component: 'layout.base',
children: [
{
name: 'user',
path: '',
component: 'view.user',
meta: {
title: 'user'
}
}
]
}
];
24 changes: 12 additions & 12 deletions examples/template-vue/src/typings/elegant-router.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,17 @@ declare module "@elegant-router/types" {
"403": "/403";
"404": "/404";
"500": "/500";
"demo-a": "/demo-a";
"demo-a_child1": "/demo-a/child1";
"demo-a_child2": "/demo-a/child2";
"demo-a_child2_child3": "/demo-a/child2/child3";
"demo-a_child3": "/demo-a/child3";
"demo3": "/demo3/:id";
"about": "/about";
"list": "/list";
"list_detail": "/list/detail";
"list_home": "/list/home";
"multi-menu": "/multi-menu";
"multi-menu_first": "/multi-menu/first";
"multi-menu_first_child": "/multi-menu/first/child";
"multi-menu_second": "/multi-menu/second";
"multi-menu_second_child": "/multi-menu/second/child";
"multi-menu_second_child_home": "/multi-menu/second/child/home";
"user": "/user/:id";
};

/**
Expand Down Expand Up @@ -61,9 +60,10 @@ declare module "@elegant-router/types" {
| "403"
| "404"
| "500"
| "demo-a"
| "demo3"
| "about"
| "list"
| "multi-menu"
| "user"
>;

/**
Expand All @@ -74,12 +74,12 @@ declare module "@elegant-router/types" {
| "403"
| "404"
| "500"
| "demo-a_child1"
| "demo-a_child2_child3"
| "demo-a_child3"
| "demo3"
| "about"
| "list_detail"
| "list_home"
| "multi-menu_first_child"
| "multi-menu_second_child_home"
| "user"
>;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts"></script>

<template>
<div>403</div>
</template>

<script setup lang="ts"></script>

<style scoped></style>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts"></script>

<template>
<div>404</div>
</template>

<script setup lang="ts"></script>

<style scoped></style>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts"></script>

<template>
<div>500</div>
</template>

<script setup lang="ts"></script>

<style scoped></style>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts"></script>

<template>
<div>demo-a-child1</div>
<div>About</div>
</template>

<script setup lang="ts"></script>

<style scoped></style>

This file was deleted.

7 changes: 0 additions & 7 deletions examples/template-vue/src/views/demo-a/child3/index.vue

This file was deleted.

7 changes: 7 additions & 0 deletions examples/template-vue/src/views/list/detail/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script setup lang="ts"></script>

<template>
<div>List Detail</div>
</template>

<style scoped></style>
7 changes: 7 additions & 0 deletions examples/template-vue/src/views/list/home/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script setup lang="ts"></script>

<template>
<div>List Home</div>
</template>

<style scoped></style>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts"></script>

<template>
<div>demo-a-child1</div>
<div>MultiMenu First Child</div>
</template>

<script setup lang="ts"></script>

<style scoped></style>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts"></script>

<template>
<div>demo-a-child1</div>
<div>MultiMenu Second Child Home</div>
</template>

<script setup lang="ts"></script>

<style scoped></style>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts"></script>

<template>
<div>demo3-[id]</div>
<div>User [id]</div>
</template>

<script setup lang="ts"></script>

<style scoped></style>
2 changes: 1 addition & 1 deletion packages/core/src/core/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { normalizeWindowsPath } from './path';
*/
export function createPluginOptions(options?: Partial<ElegantRouterOption>): ElegantRouterOption {
const PAGE_DIR = 'src/views';
const PAGE_PATTERNS = ['**/index.{vue,tsx,jsx}', '**/[[]*[]].{vue,tsx,jsx}'];
const PAGE_PATTERNS = ['**/index.vue', '**/[[]*[]].vue'];
const PAGE_EXCLUDE_PATTERNS = ['**/components/**'];

const opts: ElegantRouterOption = {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface ElegantRouterOption {
alias: Record<string, string>;
/**
* the patterns to match the page files
* @default ["**‍/index.{vue,tsx,jsx}", "**‍/[[]*[]].{vue,tsx,jsx}"]
* @default ["**‍/index.vue", "**‍/[[]*[]].vue"]
* @example "index.vue", "[id.vue]"
* @link the detail syntax: https://github.com/micromatch/micromatch
*/
Expand Down

0 comments on commit 6a474af

Please sign in to comment.