@@ -118,11 +118,13 @@ import { IPublicModelPluginContext } from '@alilc/lowcode-types';
118118const BuiltinPluginRegistry = (ctx: IPublicModelPluginContext, options: any) => {
119119 return {
120120 async init() {
121- // 1.0.4 之后的传值方式,通过 register(xxx, options)
122- // 取值通过 options
121+ // 直接传值方式:
122+ // 通过 register(xxx, options) 传入
123+ // 通过 options 取出
123124
124- // 1.0.4 之前的传值方式,通过 init(..., preference)
125- // 取值通过 ctx.preference.getValue()
125+ // 引擎初始化时也可以设置某插件的全局配置项:
126+ // 通过 engine.init(..., preference) 传入
127+ // 通过 ctx.preference.getValue() 取出
126128 },
127129 };
128130}
@@ -155,7 +157,6 @@ BuiltinPluginRegistry.meta = {
155157 },
156158}
157159
158- // 从 1.0.4 开始,支持直接在 pluginCreator 的第二个参数 options 获取入参
159160await plugins.register(BuiltinPluginRegistry, { key1: 'abc', key5: 'willNotPassToPlugin' });
160161` ` `
161162
@@ -164,8 +165,11 @@ await plugins.register(BuiltinPluginRegistry, { key1: 'abc', key5: 'willNotPassT
164165获取指定插件
165166
166167` ` ` typescript
167- function get(pluginName: string): IPublicModelPluginInstance;
168-
168+ /**
169+ * 获取指定插件
170+ * get plugin instance by name
171+ */
172+ get(pluginName: string): IPublicModelPluginInstance | null;
169173` ` `
170174
171175关联模型 [IPublicModelPluginInstance ](./model /plugin -instance )
@@ -175,8 +179,11 @@ function get(pluginName: string): IPublicModelPluginInstance;
175179获取所有的插件实例
176180
177181` ` ` typescript
178- function getAll(): IPublicModelPluginInstance[];
179-
182+ /**
183+ * 获取所有的插件实例
184+ * get all plugin instances
185+ */
186+ getAll(): IPublicModelPluginInstance[];
180187` ` `
181188
182189关联模型 [IPublicModelPluginInstance ](./model /plugin -instance )
@@ -186,17 +193,37 @@ function getAll(): IPublicModelPluginInstance[];
186193判断是否有指定插件
187194
188195` ` ` typescript
189- function has(pluginName: string): boolean;
190-
196+ /**
197+ * 判断是否有指定插件
198+ * check if plugin with certain name exists
199+ */
200+ has(pluginName: string): boolean;
191201` ` `
192202
193203### delete
194204
195205删除指定插件
196206
197207` ` ` typescript
198- function delete(pluginName: string): void;
208+ /**
209+ * 删除指定插件
210+ * delete plugin instance by name
211+ */
212+ delete(pluginName: string): void;
213+ ` ` `
199214
215+ ### getPluginPreference
216+
217+ 引擎初始化时可以提供全局配置给到各插件,通过这个方法可以获得本插件对应的配置
218+
219+ ` ` ` typescript
220+ /**
221+ * 引擎初始化时可以提供全局配置给到各插件,通过这个方法可以获得本插件对应的配置
222+ * use this to get preference config for this plugin when engine.init() called
223+ */
224+ getPluginPreference(
225+ pluginName: string,
226+ ): Record<string, IPublicTypePreferenceValueType> | null | undefined;
200227` ` `
201228
202229## 相关类型定义
0 commit comments