feat: optimize ts definition

This commit is contained in:
liujuping 2023-03-08 18:07:36 +08:00 committed by 林熠
parent aaedee159d
commit 88961aa640
10 changed files with 30 additions and 14 deletions

View File

@ -326,7 +326,7 @@ export class DocumentModel implements IDocumentModel {
}; };
} }
onChangeNodeChildren(fn: (info: IPublicTypeOnChangeOptions) => void): IPublicTypeDisposable { onChangeNodeChildren(fn: (info: IPublicTypeOnChangeOptions<INode>) => void): IPublicTypeDisposable {
this.designer.editor?.eventBus.on(EDITOR_EVENT.NODE_VISIBLE_CHANGE, fn); this.designer.editor?.eventBus.on(EDITOR_EVENT.NODE_VISIBLE_CHANGE, fn);
return () => { return () => {

View File

@ -83,7 +83,7 @@ export class ModalNodesManager implements IModalNodesManager {
} }
private addNode(node: INode) { private addNode(node: INode) {
if (node.componentMeta.isModal) { if (node?.componentMeta.isModal) {
this.hideModalNodes(); this.hideModalNodes();
this.modalNodes.push(node); this.modalNodes.push(node);
this.addNodeEvent(node); this.addNodeEvent(node);

View File

@ -119,6 +119,7 @@ const pluginContextApiAssembler: ILowCodePluginContextApiAssembler = {
context.canvas = canvas; context.canvas = canvas;
context.plugins = plugins; context.plugins = plugins;
context.logger = new Logger({ level: 'warn', bizName: `plugin:${pluginName}` }); context.logger = new Logger({ level: 'warn', bizName: `plugin:${pluginName}` });
context.workspace = workspace;
}, },
}; };

View File

@ -37,7 +37,7 @@ export class Resource implements IPublicModelResource {
return this[resourceSymbol].children.map((child) => new Resource(child)); return this[resourceSymbol].children.map((child) => new Resource(child));
} }
get viewType() { get viewName() {
return this[resourceSymbol].viewType; return this[resourceSymbol].viewName;
} }
} }

View File

@ -179,13 +179,13 @@ export interface IPublicModelDocumentModel<
* document children * document children
* @param fn * @param fn
*/ */
onChangeNodeChildren(fn: (info: IPublicTypeOnChangeOptions) => void): IPublicTypeDisposable; onChangeNodeChildren(fn: (info: IPublicTypeOnChangeOptions<Node>) => void): IPublicTypeDisposable;
/** /**
* document * document
* @param fn * @param fn
*/ */
onChangeNodeProp(fn: (info: IPublicTypePropChangeOptions) => void): IPublicTypeDisposable; onChangeNodeProp(fn: (info: IPublicTypePropChangeOptions<Node>) => void): IPublicTypeDisposable;
/** /**
* import schema event * import schema event

View File

@ -5,11 +5,15 @@ export interface IPublicModelResource {
get icon(): ReactElement | undefined; get icon(): ReactElement | undefined;
get options(): Object; get options(): Record<string, any>;
get name(): string | undefined; get name(): string | undefined;
get type(): string | undefined; get type(): string | undefined;
get category(): string | undefined; get category(): string | undefined;
get children(): IPublicModelResource[];
get viewName(): string | undefined;
} }

View File

@ -1,6 +1,8 @@
import { IPublicModelNode } from '..'; import { IPublicModelNode } from '..';
export interface IPublicTypeOnChangeOptions { export interface IPublicTypeOnChangeOptions<
Node = IPublicModelNode
> {
type: string; type: string;
node: IPublicModelNode; node: Node;
} }

View File

@ -3,10 +3,12 @@ import {
IPublicModelProp, IPublicModelProp,
} from '../model'; } from '../model';
export interface IPublicTypePropChangeOptions { export interface IPublicTypePropChangeOptions<
Node = IPublicModelNode
> {
key?: string | number; key?: string | number;
prop?: IPublicModelProp; prop?: IPublicModelProp;
node: IPublicModelNode; node: Node;
newValue: any; newValue: any;
oldValue: any; oldValue: any;
} }

View File

@ -1,14 +1,21 @@
import { ReactElement } from 'react'; import { ReactElement } from 'react';
export interface IPublicResourceData { export interface IPublicResourceData {
/** 资源名字 */
resourceName: string; resourceName: string;
/** 资源标题 */
title: string; title: string;
/** 分类 */
category?: string; category?: string;
viewType?: string; /** 资源视图 */
viewName?: string;
/** 资源 icon */
icon?: ReactElement; icon?: ReactElement;
/** 资源其他配置 */
options: { options: {
[key: string]: any; [key: string]: any;
}; };
/** 资源子元素 */
children?: IPublicResourceData[]; children?: IPublicResourceData[];
} }

View File

@ -17,8 +17,8 @@ export class Resource implements IPublicModelResource {
return this.resourceType.name; return this.resourceType.name;
} }
get viewType() { get viewName() {
return this.resourceData.viewType; return this.resourceData.viewName || (this.resourceData as any).viewType;
} }
get description() { get description() {