Merge branch 'feat/componentsMapAndUtilsMap' into 'release/1.0.48'

完善 schema 中的 componentsMap 和 utils 信息



See merge request !1250196
This commit is contained in:
力皓 2021-05-12 18:02:43 +08:00
commit 567b1813f9
2 changed files with 17 additions and 0 deletions

View File

@ -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 () => {

View File

@ -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(),
});
}