mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-02-28 21:20:28 +00:00
fix: 修复组件元数据更新后 SettingTopEntry 未同步更新的 bug
This commit is contained in:
parent
a2c8bc26f1
commit
8b0c9189e2
@ -23,6 +23,7 @@ import { IconRemove } from './icons/remove';
|
||||
import { IconClone } from './icons/clone';
|
||||
import { ReactElement } from 'react';
|
||||
import { IconHidden } from './icons/hidden';
|
||||
import EventEmitter from 'events';
|
||||
|
||||
function ensureAList(list?: string | string[]): string[] | null {
|
||||
if (!list) {
|
||||
@ -66,6 +67,8 @@ export class ComponentMeta {
|
||||
|
||||
private _npm?: NpmInfo;
|
||||
|
||||
private emitter: EventEmitter = new EventEmitter();
|
||||
|
||||
get npm() {
|
||||
return this._npm;
|
||||
}
|
||||
@ -229,6 +232,11 @@ export class ComponentMeta {
|
||||
this._isContainer = false;
|
||||
this._isModal = false;
|
||||
}
|
||||
this.emitter.emit('metadata_change');
|
||||
}
|
||||
|
||||
refreshMetadata() {
|
||||
this.parseMetadata(this.getMetadata());
|
||||
}
|
||||
|
||||
private transformMetadata(metadta: ComponentMetadata): TransformedComponentMetadata {
|
||||
@ -297,6 +305,13 @@ export class ComponentMeta {
|
||||
return true;
|
||||
}
|
||||
|
||||
onMetadataChange(fn: (args: any) => void): () => void {
|
||||
this.emitter.on('metadata_change', fn);
|
||||
return () => {
|
||||
this.emitter.removeListener('metadata_change', fn);
|
||||
};
|
||||
}
|
||||
|
||||
// compatiable vision
|
||||
prototype?: any;
|
||||
}
|
||||
|
||||
@ -80,6 +80,8 @@ export class SettingTopEntry implements SettingEntry {
|
||||
|
||||
// clear fields
|
||||
this.setupItems();
|
||||
|
||||
this.setupEvents();
|
||||
}
|
||||
|
||||
private setupComponentMeta() {
|
||||
@ -120,6 +122,12 @@ export class SettingTopEntry implements SettingEntry {
|
||||
}
|
||||
}
|
||||
|
||||
private setupEvents() {
|
||||
this.componentMeta?.onMetadataChange(() => {
|
||||
this.setupItems();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前属性值
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user