File tree Expand file tree Collapse file tree 4 files changed +49
-4
lines changed
Expand file tree Collapse file tree 4 files changed +49
-4
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,13 @@ export * from '@zelpis/builder/plugins'
1010export * from '@zelpis/render/plugins'
1111
1212export interface ZelpisPluginOption {
13+ /**
14+ * 构建插件配置
15+ */
1316 build ?: BuilderPluginOption
17+ /**
18+ * 渲染插件配置
19+ */
1420 render ?: RenderPluginOption
1521}
1622
Original file line number Diff line number Diff line change 1+ import type { ReactNode } from 'react'
12import type { Root } from 'react-dom/client'
2- import type { App } from 'vue'
3+ import type { App , Component } from 'vue'
34import { once } from '@zelpis/shared'
45
56interface BaseBootOption {
7+ /**
8+ * 渲染类型, 当前只支持 csr
9+ */
610 type ?: 'csr' | 'ssr'
11+ /**
12+ * 框架, 当前只支持 react 和 vue
13+ */
714 framework : 'react' | 'vue'
8- Component : ( props : any ) => any
15+ /**
16+ * 渲染组件
17+ */
18+ Component : any
19+ /**
20+ * 挂载函数
21+ */
922 mount ?: ( app : any ) => void
1023}
1124
1225interface ReactBootOption extends BaseBootOption {
1326 framework : 'react'
27+ Component : ( props : any ) => ReactNode
1428 mount ?: ( app : Root ) => void
1529}
1630
1731interface VueBootOption extends BaseBootOption {
1832 framework : 'vue'
33+ Component : Component
1934 mount ?: ( app : App ) => void
2035}
2136
@@ -42,7 +57,7 @@ async function createComponent(
4257) : Promise < any > {
4358 if ( framework === 'react' ) {
4459 const { createElement } = await import ( 'react' )
45- return createElement ( Component , props )
60+ return createElement ( Component as ReactBootOption [ 'Component' ] , props )
4661 }
4762 if ( framework === 'vue' ) {
4863 if ( option . type === 'csr' ) {
Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ const APP_BODY_START_PLACEHOLDER = STANDARD_PLACEHOLDERS.APP_BODY_START
1616const APP_INJECT_SCRIPT_PLACEHOLDER = STANDARD_PLACEHOLDERS . APP_INJECT_SCRIPT
1717
1818export interface RenderPluginOption {
19+ /**
20+ * 用于索引 entry 的相对路径
21+ */
1922 baseDir ?: string
2023}
2124
Original file line number Diff line number Diff line change @@ -32,25 +32,46 @@ export interface HtmlConfig {
3232 * 入口配置
3333 */
3434export interface Entry {
35+ /**
36+ * url base path
37+ */
3538 basePath : string
39+ /**
40+ * 入口文件路径
41+ */
3642 entryPath : string
43+ /**
44+ * 当前入口文件对应的 DSL 文件夹路径
45+ */
3746 dslPath ?: string
47+ /**
48+ * 当前入口文件对应的 DSL 文件
49+ */
3850 dslEntrys ?: any [ ]
51+ /**
52+ * HTML 配置
53+ */
3954 html ?: HtmlConfig
4055}
4156
4257/**
4358 * 解析 HTML 选项
4459 */
4560export interface ResolveHtmlOptions {
46- entry : Entry
61+ entry : Omit < Entry , 'dslEntrys' >
4762 defaultHtml ?: HtmlConfig
4863 rootDir ?: string
4964 ensurePlaceholders ?: string [ ]
5065}
5166
5267export interface ZElpisConfig {
68+ /**
69+ * 入口配置
70+ */
5371 entrys : Entry [ ]
72+ /**
73+ * 默认 HTML 配置
74+ */
5475 defaultHtml ?: HtmlConfig
5576}
5677
You can’t perform that action at this time.
0 commit comments