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

View File

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

View File

@ -119,6 +119,7 @@ const pluginContextApiAssembler: ILowCodePluginContextApiAssembler = {
context.canvas = canvas;
context.plugins = plugins;
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));
}
get viewType() {
return this[resourceSymbol].viewType;
get viewName() {
return this[resourceSymbol].viewName;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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