feat(projects): add new route plugin @soybeanjs/vite-plugin-vue-page-route [集成新的路由插件]

This commit is contained in:
Soybean
2023-01-15 23:32:40 +08:00
parent f71812d622
commit 3131e00f0f
9 changed files with 357 additions and 172 deletions

View File

@ -1,4 +1,4 @@
const about: AuthRoute.Route = {
const about1: AuthRoute.Route = {
name: 'about',
path: '/about',
component: 'self',
@ -12,4 +12,4 @@ const about: AuthRoute.Route = {
}
};
export default about;
export default about1;

122
src/typings/page-route.d.ts vendored Normal file
View File

@ -0,0 +1,122 @@
declare namespace PageRoute {
/**
* the root route key
* @translate 根路由
*/
type RootRouteKey = 'root';
/**
* the not found route, which catch the invalid route path
* @translate 未找到路由(捕获无效路径的路由)
*/
type NotFoundRouteKey = 'not-found';
/**
* the route key
* @translate 页面路由
*/
type RouteKey =
| '403'
| '404'
| '500'
| 'constant-page'
| 'login'
| 'not-found'
| 'about'
| 'auth-demo'
| 'auth-demo_permission'
| 'auth-demo_super'
| 'component'
| 'component_button'
| 'component_card'
| 'component_table'
| 'dashboard'
| 'dashboard_analysis'
| 'dashboard_workbench'
| 'document'
| 'document_naive'
| 'document_project-link'
| 'document_project'
| 'document_vite'
| 'document_vue'
| 'exception'
| 'exception_403'
| 'exception_404'
| 'exception_500'
| 'function'
| 'function_tab-detail'
| 'function_tab-multi-detail'
| 'function_tab'
| 'management'
| 'management_auth'
| 'management_role'
| 'management_route'
| 'management_user'
| 'multi-menu'
| 'multi-menu_first'
| 'multi-menu_first_second-new'
| 'multi-menu_first_second-new_third'
| 'multi-menu_first_second'
| 'plugin'
| 'plugin_charts'
| 'plugin_charts_antv'
| 'plugin_charts_echarts'
| 'plugin_copy'
| 'plugin_editor'
| 'plugin_editor_markdown'
| 'plugin_editor_quill'
| 'plugin_icon'
| 'plugin_map'
| 'plugin_print'
| 'plugin_swiper'
| 'plugin_video';
/**
* last degree route key, which has the page file
* @translate 最后一级路由(该级路有对应的页面文件)
*/
type LastDegreeRouteKey = Extract<
RouteKey,
| '403'
| '404'
| '500'
| 'constant-page'
| 'login'
| 'not-found'
| 'about'
| 'auth-demo_permission'
| 'auth-demo_super'
| 'component_button'
| 'component_card'
| 'component_table'
| 'dashboard_analysis'
| 'dashboard_workbench'
| 'document_naive'
| 'document_project-link'
| 'document_project'
| 'document_vite'
| 'document_vue'
| 'exception_403'
| 'exception_404'
| 'exception_500'
| 'function_tab-detail'
| 'function_tab-multi-detail'
| 'function_tab'
| 'management_auth'
| 'management_role'
| 'management_route'
| 'management_user'
| 'multi-menu_first_second-new_third'
| 'multi-menu_first_second'
| 'plugin_charts_antv'
| 'plugin_charts_echarts'
| 'plugin_copy'
| 'plugin_editor_markdown'
| 'plugin_editor_quill'
| 'plugin_icon'
| 'plugin_map'
| 'plugin_print'
| 'plugin_swiper'
| 'plugin_video'
>;
}

View File

@ -5,13 +5,13 @@ declare namespace AuthRoute {
/** 捕获无效路由的路由路径 */
type NotFoundRoutePath = '/:pathMatch(.*)*';
type RootRouteKey = RouterPage.RootRouteKey;
type RootRouteKey = PageRoute.RootRouteKey;
type NotFoundRouteKey = RouterPage.NotFoundRouteKey;
type NotFoundRouteKey = PageRoute.NotFoundRouteKey;
type RouteKey = RouterPage.RouteKey;
type RouteKey = PageRoute.RouteKey;
type LastDegreeRouteKey = RouterPage.LastDegreeRouteKey;
type LastDegreeRouteKey = PageRoute.LastDegreeRouteKey;
type AllRouteKey = RouteKey | RootRouteKey | NotFoundRouteKey;

View File

@ -1,67 +0,0 @@
declare namespace RouterPage {
/** 根路由 */
type RootRouteKey = 'root';
/** 未找到路由(捕获无效路径的路由) */
type NotFoundRouteKey = 'not-found';
/** 页面路由 */
type RouteKey =
| '403'
| '404'
| '500'
| 'about'
| 'auth-demo'
| 'auth-demo_permission'
| 'auth-demo_super'
| 'component'
| 'component_button'
| 'component_card'
| 'component_table'
| 'constant-page'
| 'dashboard'
| 'dashboard_analysis'
| 'dashboard_workbench'
| 'document'
| 'document_naive'
| 'document_project'
| 'document_project-link'
| 'document_vite'
| 'document_vue'
| 'exception'
| 'exception_403'
| 'exception_404'
| 'exception_500'
| 'function'
| 'function_tab'
| 'function_tab-detail'
| 'function_tab-multi-detail'
| 'login'
| 'management'
| 'management_auth'
| 'management_role'
| 'management_route'
| 'management_user'
| 'multi-menu'
| 'multi-menu_first'
| 'multi-menu_first_second'
| 'multi-menu_first_second-new'
| 'multi-menu_first_second-new_third'
| 'not-found'
| 'plugin'
| 'plugin_charts'
| 'plugin_charts_antv'
| 'plugin_charts_echarts'
| 'plugin_copy'
| 'plugin_editor'
| 'plugin_editor_markdown'
| 'plugin_editor_quill'
| 'plugin_icon'
| 'plugin_map'
| 'plugin_print'
| 'plugin_swiper'
| 'plugin_video';
/** 最后一级路由(该级路有对应的vue文件) */
type LastDegreeRouteKey = Extract<RouteKey, '403' | '404' | '500' | 'about' | 'auth-demo_permission' | 'auth-demo_super' | 'component_button' | 'component_card' | 'component_table' | 'constant-page' | 'dashboard_analysis' | 'dashboard_workbench' | 'document_naive' | 'document_project' | 'document_project-link' | 'document_vite' | 'document_vue' | 'exception_403' | 'exception_404' | 'exception_500' | 'function_tab' | 'function_tab-detail' | 'function_tab-multi-detail' | 'login' | 'management_auth' | 'management_role' | 'management_route' | 'management_user' | 'multi-menu_first_second' | 'multi-menu_first_second-new_third' | 'not-found' | 'plugin_charts_antv' | 'plugin_charts_echarts' | 'plugin_copy' | 'plugin_editor_markdown' | 'plugin_editor_quill' | 'plugin_icon' | 'plugin_map' | 'plugin_print' | 'plugin_swiper' | 'plugin_video'>
}

View File

@ -1,6 +1,9 @@
import type { RouteComponent } from 'vue-router';
export const views: Record<RouterPage.LastDegreeRouteKey, RouteComponent | (() => Promise<RouteComponent>)> = {
export const views: Record<
PageRoute.LastDegreeRouteKey,
RouteComponent | (() => Promise<{ default: RouteComponent }>)
> = {
403: () => import('./_builtin/403/index.vue'),
404: () => import('./_builtin/404/index.vue'),
500: () => import('./_builtin/500/index.vue'),