Skip to content

Commit cfc22f7

Browse files
liujupingJackLian
authored andcommitted
feat: add simulatorRender shell
1 parent cf2f5c2 commit cfc22f7

File tree

9 files changed

+93
-9
lines changed

9 files changed

+93
-9
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: SimulatorRender
3+
sidebar_position: 6
4+
---
5+
> **@types** [IPublicModelSimulatorRender](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/simulator-render.ts)<br/>
6+
> **@since** v1.0.0
7+
8+
## 基本介绍
9+
10+
画布节点选中模型
11+
12+
## 属性
13+
### components
14+
15+
画布组件列表
16+
17+
```typescript
18+
/**
19+
* 画布组件列表
20+
*/
21+
components: {
22+
[key: string]: any;
23+
}
24+
```
25+
26+
## 方法
27+
28+
### rerender
29+
30+
触发画布重新渲染
31+
32+
```typescript
33+
/**
34+
* 触发画布重新渲染
35+
*/
36+
rerender: () => void;
37+
```
38+

docs/docs/api/simulatorHost.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ get(key: string): any;
5050
```
5151

5252
### rerender
53-
刷新渲染画布
53+
触发组件构建,并刷新渲染画布
5454

5555
```typescript
5656
/**
57-
* 刷新渲染画布
57+
* 触发组件构建,并刷新渲染画布
5858
* make simulator render again
5959
*/
6060
rerender(): void;

packages/engine/src/modules/symbols.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
skeletonItemSymbol,
1515
editorCabinSymbol,
1616
skeletonCabinSymbol,
17+
simulatorRenderSymbol,
1718
} from '@alilc/lowcode-shell';
1819

1920
export default {
@@ -32,4 +33,5 @@ export default {
3233
propSymbol,
3334
simulatorHostSymbol,
3435
skeletonItemSymbol,
36+
simulatorRenderSymbol,
3537
};

packages/shell/src/api/simulator-host.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import {
22
BuiltinSimulatorHost,
33
} from '@alilc/lowcode-designer';
44
import { simulatorHostSymbol, nodeSymbol } from '../symbols';
5-
import { IPublicApiSimulatorHost, IPublicModelNode } from '@alilc/lowcode-types';
5+
import { IPublicApiSimulatorHost, IPublicModelNode, IPublicModelSimulatorRender } from '@alilc/lowcode-types';
6+
import { SimulatorRender } from '../model/simulator-render';
67

78
export class SimulatorHost implements IPublicApiSimulatorHost {
89
private readonly [simulatorHostSymbol]: BuiltinSimulatorHost;
@@ -30,8 +31,12 @@ export class SimulatorHost implements IPublicApiSimulatorHost {
3031
return this[simulatorHostSymbol].contentDocument;
3132
}
3233

33-
get renderer(): any {
34-
return this[simulatorHostSymbol].renderer;
34+
get renderer(): IPublicModelSimulatorRender | undefined {
35+
if (this[simulatorHostSymbol].renderer) {
36+
return SimulatorRender.create(this[simulatorHostSymbol].renderer);
37+
}
38+
39+
return undefined;
3540
}
3641

3742
/**
@@ -61,7 +66,7 @@ export class SimulatorHost implements IPublicApiSimulatorHost {
6166
}
6267

6368
/**
64-
* 刷新渲染画布
69+
* 触发组件构建,并刷新渲染画布
6570
*/
6671
rerender(): void {
6772
this[simulatorHostSymbol].rerender();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { IPublicModelSimulatorRender } from '@alilc/lowcode-types';
2+
import { simulatorRenderSymbol } from '../symbols';
3+
import { BuiltinSimulatorRenderer } from '@alilc/lowcode-designer';
4+
5+
export class SimulatorRender implements IPublicModelSimulatorRender {
6+
private readonly [simulatorRenderSymbol]: BuiltinSimulatorRenderer;
7+
8+
constructor(simulatorRender: BuiltinSimulatorRenderer) {
9+
this[simulatorRenderSymbol] = simulatorRender;
10+
}
11+
12+
static create(simulatorRender: BuiltinSimulatorRenderer): IPublicModelSimulatorRender {
13+
return new SimulatorRender(simulatorRender);
14+
}
15+
16+
get components() {
17+
return this[simulatorRenderSymbol].components;
18+
}
19+
20+
rerender() {
21+
return this[simulatorRenderSymbol].rerender();
22+
}
23+
}

packages/shell/src/symbols.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const dragonSymbol = Symbol('dragon');
2121
export const componentMetaSymbol = Symbol('componentMeta');
2222
export const dropLocationSymbol = Symbol('dropLocation');
2323
export const simulatorHostSymbol = Symbol('simulatorHost');
24+
export const simulatorRenderSymbol = Symbol('simulatorRender');
2425
export const dragObjectSymbol = Symbol('dragObject');
2526
export const locateEventSymbol = Symbol('locateEvent');
2627
export const designerCabinSymbol = Symbol('designerCabin');

packages/types/src/shell/api/simulator-host.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { IPublicModelNode } from '../model';
2-
1+
import { IPublicModelNode, IPublicModelSimulatorRender } from '../model';
32

43
export interface IPublicApiSimulatorHost {
4+
55
/**
66
* 获取 contentWindow
77
* @experimental unstable api, pay extra caution when trying to use it
@@ -17,7 +17,7 @@ export interface IPublicApiSimulatorHost {
1717
/**
1818
* @experimental unstable api, pay extra caution when trying to use it
1919
*/
20-
get renderer(): any;
20+
get renderer(): IPublicModelSimulatorRender | undefined;
2121

2222
/**
2323
* 设置若干用于画布渲染的变量,比如画布大小、locale 等。

packages/types/src/shell/model/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ export * from './clipboard';
3232
export * from './setting-field';
3333
export * from './editor-view';
3434
export * from './skeleton-item';
35+
export * from './simulator-render';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export interface IPublicModelSimulatorRender {
2+
3+
/**
4+
* 画布组件列表
5+
*/
6+
components: {
7+
[key: string]: any;
8+
};
9+
10+
/**
11+
* 触发画布重新渲染
12+
*/
13+
rerender: () => void;
14+
}

0 commit comments

Comments
 (0)