mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-07 19:17:07 +00:00
37 lines
819 B
TypeScript
37 lines
819 B
TypeScript
import { EditorViewOptions, ResourceOptions } from '.';
|
|
|
|
export class Resource {
|
|
constructor(options: ResourceOptions) {
|
|
if (options.editorViews) {
|
|
options.editorViews.forEach((d: any) => {
|
|
this.editorViewMap.set(d.name, d);
|
|
});
|
|
}
|
|
|
|
this.options = options;
|
|
}
|
|
|
|
options: ResourceOptions;
|
|
|
|
editorViewMap: Map<string, EditorViewOptions> = new Map<string, EditorViewOptions>();
|
|
|
|
init(ctx: any) {
|
|
this.options.init(ctx);
|
|
}
|
|
|
|
async import(schema: any) {
|
|
return await this.options.import?.(schema);
|
|
}
|
|
|
|
getEditorView(name: string) {
|
|
return this.editorViewMap.get(name);
|
|
}
|
|
|
|
get defaultViewType() {
|
|
return this.options.defaultViewType || this.editorViewMap.keys().next().value;
|
|
}
|
|
|
|
get editorViews() {
|
|
return Array.from(this.editorViewMap.values());
|
|
}
|
|
} |