mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-12 17:08:14 +00:00
feat: 完善 schema 中的 componentsMap 和 utils 信息
This commit is contained in:
parent
da3393a126
commit
f3352231a0
@ -557,6 +557,7 @@ export class DocumentModel {
|
||||
const node = this.export(TransformStage.Save);
|
||||
const data = {
|
||||
componentsMap: this.getComponentsMap(extraComps),
|
||||
utils: this.getUtilsMap(),
|
||||
componentsTree: [node],
|
||||
};
|
||||
return data;
|
||||
@ -673,6 +674,19 @@ export class DocumentModel {
|
||||
return componentsMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 schema 中的 utils 节点,当前版本不判断页面中使用了哪些 utils,直接返回资产包中所有的 utils
|
||||
* @returns
|
||||
*/
|
||||
getUtilsMap() {
|
||||
return this.designer?.editor?.get('assets')?.utils?.map((item: any) => ({
|
||||
name: item.name,
|
||||
type: item.type || 'npm',
|
||||
// TODO 当前只有 npm 类型,content 直接设置为 item.npm,有 function 类型之后需要处理
|
||||
content: item.npm
|
||||
}));
|
||||
}
|
||||
|
||||
onNodeCreate(func: (node: Node) => void) {
|
||||
this.emitter.on('nodecreate', func);
|
||||
return () => {
|
||||
|
||||
@ -369,8 +369,11 @@ class Prototype {
|
||||
}
|
||||
|
||||
setPackageName(name: string) {
|
||||
// 从资产包中获取包的更多信息
|
||||
const packageInfo = designer?.editor?.get('assets')?.packages?.find((item: any) => item.package === name);
|
||||
this.meta.setNpm({
|
||||
package: name,
|
||||
version: packageInfo?.version,
|
||||
componentName: this.getComponentName(),
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user