mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-10 18:03:01 +00:00
feat: add simulatorRender shell
This commit is contained in:
parent
cf2f5c29bc
commit
cfc22f7ecc
38
docs/docs/api/model/simulatorRender.md
Normal file
38
docs/docs/api/model/simulatorRender.md
Normal 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;
|
||||
```
|
||||
|
||||
@ -50,11 +50,11 @@ get(key: string): any;
|
||||
```
|
||||
|
||||
### rerender
|
||||
刷新渲染画布
|
||||
触发组件构建,并刷新渲染画布
|
||||
|
||||
```typescript
|
||||
/**
|
||||
* 刷新渲染画布
|
||||
* 触发组件构建,并刷新渲染画布
|
||||
* make simulator render again
|
||||
*/
|
||||
rerender(): void;
|
||||
|
||||
@ -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,
|
||||
};
|
||||
|
||||
@ -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();
|
||||
|
||||
23
packages/shell/src/model/simulator-render.ts
Normal file
23
packages/shell/src/model/simulator-render.ts
Normal 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();
|
||||
}
|
||||
}
|
||||
@ -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');
|
||||
|
||||
@ -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 等。
|
||||
|
||||
@ -32,3 +32,4 @@ export * from './clipboard';
|
||||
export * from './setting-field';
|
||||
export * from './editor-view';
|
||||
export * from './skeleton-item';
|
||||
export * from './simulator-render';
|
||||
|
||||
14
packages/types/src/shell/model/simulator-render.ts
Normal file
14
packages/types/src/shell/model/simulator-render.ts
Normal file
@ -0,0 +1,14 @@
|
||||
export interface IPublicModelSimulatorRender {
|
||||
|
||||
/**
|
||||
* 画布组件列表
|
||||
*/
|
||||
components: {
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
/**
|
||||
* 触发画布重新渲染
|
||||
*/
|
||||
rerender: () => void;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user