diff --git a/examples/template-vue/src/router/elegant/imports.ts b/examples/template-vue/src/router/elegant/imports.ts index d665323..28529d5 100644 --- a/examples/template-vue/src/router/elegant/imports.ts +++ b/examples/template-vue/src/router/elegant/imports.ts @@ -15,13 +15,13 @@ export const layouts: Record Promise Promise)> = { - 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"), }; diff --git a/examples/template-vue/src/router/elegant/routes.ts b/examples/template-vue/src/router/elegant/routes.ts index 4a9f03c..0b6b7d9 100644 --- a/examples/template-vue/src/router/elegant/routes.ts +++ b/examples/template-vue/src/router/elegant/routes.ts @@ -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' } } ] @@ -165,5 +147,19 @@ export const autoRoutes: ElegantRoute[] = [ } } ] + }, + { + path: '/user/:id', + component: 'layout.base', + children: [ + { + name: 'user', + path: '', + component: 'view.user', + meta: { + title: 'user' + } + } + ] } ]; diff --git a/examples/template-vue/src/typings/elegant-router.d.ts b/examples/template-vue/src/typings/elegant-router.d.ts index aebdfe8..bcfa2af 100644 --- a/examples/template-vue/src/typings/elegant-router.d.ts +++ b/examples/template-vue/src/typings/elegant-router.d.ts @@ -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"; }; /** @@ -61,9 +60,10 @@ declare module "@elegant-router/types" { | "403" | "404" | "500" - | "demo-a" - | "demo3" + | "about" + | "list" | "multi-menu" + | "user" >; /** @@ -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" >; /** diff --git a/examples/template-vue/src/views/403/index.vue b/examples/template-vue/src/views/_error/403/index.vue similarity index 100% rename from examples/template-vue/src/views/403/index.vue rename to examples/template-vue/src/views/_error/403/index.vue index 8032a24..88c0686 100644 --- a/examples/template-vue/src/views/403/index.vue +++ b/examples/template-vue/src/views/_error/403/index.vue @@ -1,7 +1,7 @@ + + - - diff --git a/examples/template-vue/src/views/404/index.vue b/examples/template-vue/src/views/_error/404/index.vue similarity index 100% rename from examples/template-vue/src/views/404/index.vue rename to examples/template-vue/src/views/_error/404/index.vue index 0e6ec79..ffd4796 100644 --- a/examples/template-vue/src/views/404/index.vue +++ b/examples/template-vue/src/views/_error/404/index.vue @@ -1,7 +1,7 @@ + + - - diff --git a/examples/template-vue/src/views/500/index.vue b/examples/template-vue/src/views/_error/500/index.vue similarity index 100% rename from examples/template-vue/src/views/500/index.vue rename to examples/template-vue/src/views/_error/500/index.vue index c3323bb..264ed87 100644 --- a/examples/template-vue/src/views/500/index.vue +++ b/examples/template-vue/src/views/_error/500/index.vue @@ -1,7 +1,7 @@ + + - - diff --git a/examples/template-vue/src/views/demo-a/child1/index.vue b/examples/template-vue/src/views/about/index.vue similarity index 75% rename from examples/template-vue/src/views/demo-a/child1/index.vue rename to examples/template-vue/src/views/about/index.vue index 9d218d1..0982005 100644 --- a/examples/template-vue/src/views/demo-a/child1/index.vue +++ b/examples/template-vue/src/views/about/index.vue @@ -1,7 +1,7 @@ + + - - diff --git a/examples/template-vue/src/views/demo-a/child2/child3/index.vue b/examples/template-vue/src/views/demo-a/child2/child3/index.vue deleted file mode 100644 index 69db5b6..0000000 --- a/examples/template-vue/src/views/demo-a/child2/child3/index.vue +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/examples/template-vue/src/views/demo-a/child3/index.vue b/examples/template-vue/src/views/demo-a/child3/index.vue deleted file mode 100644 index 4a09245..0000000 --- a/examples/template-vue/src/views/demo-a/child3/index.vue +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/examples/template-vue/src/views/list/detail/index.vue b/examples/template-vue/src/views/list/detail/index.vue new file mode 100644 index 0000000..aeaa3a4 --- /dev/null +++ b/examples/template-vue/src/views/list/detail/index.vue @@ -0,0 +1,7 @@ + + + + + diff --git a/examples/template-vue/src/views/list/home/index.vue b/examples/template-vue/src/views/list/home/index.vue new file mode 100644 index 0000000..7ced82c --- /dev/null +++ b/examples/template-vue/src/views/list/home/index.vue @@ -0,0 +1,7 @@ + + + + + diff --git a/examples/template-vue/src/views/multi-menu/first_child/index.vue b/examples/template-vue/src/views/multi-menu/first_child/index.vue index 9d218d1..6603876 100644 --- a/examples/template-vue/src/views/multi-menu/first_child/index.vue +++ b/examples/template-vue/src/views/multi-menu/first_child/index.vue @@ -1,7 +1,7 @@ + + - - diff --git a/examples/template-vue/src/views/multi-menu/second_child_home/index.vue b/examples/template-vue/src/views/multi-menu/second_child_home/index.vue index 9d218d1..c54f6e2 100644 --- a/examples/template-vue/src/views/multi-menu/second_child_home/index.vue +++ b/examples/template-vue/src/views/multi-menu/second_child_home/index.vue @@ -1,7 +1,7 @@ + + - - diff --git a/examples/template-vue/src/views/demo3/[id].vue b/examples/template-vue/src/views/user/[id].vue similarity index 77% rename from examples/template-vue/src/views/demo3/[id].vue rename to examples/template-vue/src/views/user/[id].vue index 37bec8d..49c5a87 100644 --- a/examples/template-vue/src/views/demo3/[id].vue +++ b/examples/template-vue/src/views/user/[id].vue @@ -1,7 +1,7 @@ + + - - diff --git a/packages/core/src/core/options.ts b/packages/core/src/core/options.ts index 0a62715..ffacc92 100644 --- a/packages/core/src/core/options.ts +++ b/packages/core/src/core/options.ts @@ -7,7 +7,7 @@ import { normalizeWindowsPath } from './path'; */ export function createPluginOptions(options?: Partial): 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 = { diff --git a/packages/core/src/types/index.ts b/packages/core/src/types/index.ts index 96fec7c..ba4e58f 100644 --- a/packages/core/src/types/index.ts +++ b/packages/core/src/types/index.ts @@ -20,7 +20,7 @@ export interface ElegantRouterOption { alias: Record; /** * 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 */