feat: add simulatorRender shell

This commit is contained in:
liujuping 2023-09-18 15:48:32 +08:00 committed by 林熠
parent cf2f5c29bc
commit cfc22f7ecc
9 changed files with 93 additions and 9 deletions

View File

@ -0,0 +1,38 @@
---
title: SimulatorRender
sidebar_position: 6
---
> **@types** [IPublicModelSimulatorRender](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/simulator-render.ts)<br/>
> **@since** v1.0.0
## 基本介绍
画布节点选中模型
## 属性
### components
画布组件列表
```typescript
/**
* 画布组件列表
*/
components: {
[key: string]: any;
}
```
## 方法
### rerender
触发画布重新渲染
```typescript
/**
* 触发画布重新渲染
*/
rerender: () => void;
```

View File

@ -50,11 +50,11 @@ get(key: string): any;
```
### rerender
刷新渲染画布
触发组件构建,并刷新渲染画布
```typescript
/**
* 刷新渲染画布
* 触发组件构建,并刷新渲染画布
* make simulator render again
*/
rerender(): void;

View File

@ -14,6 +14,7 @@ import {
skeletonItemSymbol,
editorCabinSymbol,
skeletonCabinSymbol,
simulatorRenderSymbol,
} from '@alilc/lowcode-shell';
export default {
@ -32,4 +33,5 @@ export default {
propSymbol,
simulatorHostSymbol,
skeletonItemSymbol,
simulatorRenderSymbol,
};

View File

@ -2,7 +2,8 @@ import {
BuiltinSimulatorHost,
} from '@alilc/lowcode-designer';
import { simulatorHostSymbol, nodeSymbol } from '../symbols';
import { IPublicApiSimulatorHost, IPublicModelNode } from '@alilc/lowcode-types';
import { IPublicApiSimulatorHost, IPublicModelNode, IPublicModelSimulatorRender } from '@alilc/lowcode-types';
import { SimulatorRender } from '../model/simulator-render';
export class SimulatorHost implements IPublicApiSimulatorHost {
private readonly [simulatorHostSymbol]: BuiltinSimulatorHost;
@ -30,8 +31,12 @@ export class SimulatorHost implements IPublicApiSimulatorHost {
return this[simulatorHostSymbol].contentDocument;
}
get renderer(): any {
return this[simulatorHostSymbol].renderer;
get renderer(): IPublicModelSimulatorRender | undefined {
if (this[simulatorHostSymbol].renderer) {
return SimulatorRender.create(this[simulatorHostSymbol].renderer);
}
return undefined;
}
/**
@ -61,7 +66,7 @@ export class SimulatorHost implements IPublicApiSimulatorHost {
}
/**
*
*
*/
rerender(): void {
this[simulatorHostSymbol].rerender();

View File

@ -0,0 +1,23 @@
import { IPublicModelSimulatorRender } from '@alilc/lowcode-types';
import { simulatorRenderSymbol } from '../symbols';
import { BuiltinSimulatorRenderer } from '@alilc/lowcode-designer';
export class SimulatorRender implements IPublicModelSimulatorRender {
private readonly [simulatorRenderSymbol]: BuiltinSimulatorRenderer;
constructor(simulatorRender: BuiltinSimulatorRenderer) {
this[simulatorRenderSymbol] = simulatorRender;
}
static create(simulatorRender: BuiltinSimulatorRenderer): IPublicModelSimulatorRender {
return new SimulatorRender(simulatorRender);
}
get components() {
return this[simulatorRenderSymbol].components;
}
rerender() {
return this[simulatorRenderSymbol].rerender();
}
}

View File

@ -21,6 +21,7 @@ export const dragonSymbol = Symbol('dragon');
export const componentMetaSymbol = Symbol('componentMeta');
export const dropLocationSymbol = Symbol('dropLocation');
export const simulatorHostSymbol = Symbol('simulatorHost');
export const simulatorRenderSymbol = Symbol('simulatorRender');
export const dragObjectSymbol = Symbol('dragObject');
export const locateEventSymbol = Symbol('locateEvent');
export const designerCabinSymbol = Symbol('designerCabin');

View File

@ -1,7 +1,7 @@
import { IPublicModelNode } from '../model';
import { IPublicModelNode, IPublicModelSimulatorRender } from '../model';
export interface IPublicApiSimulatorHost {
/**
* contentWindow
* @experimental unstable api, pay extra caution when trying to use it
@ -17,7 +17,7 @@ export interface IPublicApiSimulatorHost {
/**
* @experimental unstable api, pay extra caution when trying to use it
*/
get renderer(): any;
get renderer(): IPublicModelSimulatorRender | undefined;
/**
* locale

View File

@ -32,3 +32,4 @@ export * from './clipboard';
export * from './setting-field';
export * from './editor-view';
export * from './skeleton-item';
export * from './simulator-render';

View File

@ -0,0 +1,14 @@
export interface IPublicModelSimulatorRender {
/**
*
*/
components: {
[key: string]: any;
};
/**
*
*/
rerender: () => void;
}