/**
* 画布文档数据
*/
class FlowDocument {
/**
* * 节点数据定义, 节点创建时候会把数据实例化
*/
nodeDefines: [
NodePositionData,
NodeFormData,
NodeLineData
]
nodeEntities: Entity[] = []
}
/**
* 节点
*/
class FlowNodeEntity {
id: string // 只有id 不带数据
getData: (dataId: string) => EntityData
}
// 渲染线条
class LinesLayer {
/**
* 内部通过 node.getData(NodeLineData) 获取对应的数据,下同
*/
@observeEntityData(FlowNodeEntity, NodeLineData) lines: NodeLineData[]
render() {
// 渲染线条
return this.lines.map(line => <Line data={line} />)
}
}
// 渲染节点位置
class NodePositionsLayer {
@observeEntityData(FlowNodeEntity, NodePositionData) positions: NodePositionData[]
render() {
// 渲染位置及排版
}
}
// 渲染节点表单
class NodeFormsLayer {
@observeEntityData(FlowNodeEntity, NodeFormData) contents: NodeFormData[]
render() {
// 渲染节点内容
}
}
/**
* 画布实例,通过 Layer 分层渲染
*/
class Playground {
layers: [
LinesLayer, // 线条渲染
NodePositionsLayer, // 位置渲染
NodeFormsLayer // 内容渲染
],
render() {
// 画布分层渲染
return this.layers.map(layer => layer.render())
}
}