-
Notifications
You must be signed in to change notification settings - Fork 3
DesignerAPI
marstone edited this page Oct 8, 2021
·
7 revisions
- 当设计器A打开设计器B时,设计器A(父)和设计器B(子)之间的通讯标准
- 父/子设计器需分别实现
- 使用Typescript描述
/**
* 设计器工厂,负责创建设计器对象
*/
interface DesignerFactory {
/**
* 打开新窗口,获取设计器(子)对象
* @param url 子设计器的基础链接
* @param name 子设计器设计的对象机读名称
* @param dataSelector 数据目录选择器URL,可选
*/
open(url: string, name: string, dataSelector: string) : Designer
/**
* 获取打开此窗口的设计器(父)对象
*/
opener() : Designer
}
/**
* 设计器
*/
interface Designer {
/**
* 子设计器设计的对象机读名称
*/
name: string
/**
* 数据目录选择器URL,可选
*/
dataSelector: string
/**
* (子=>父)
* 读取当前设计内容的源码
*/
load() : Promise<DesignerSource>
/**
* (子=>父)
* @param name 当前设计内容机读名称
* @param source 设计内容源码
* @param timestamp,读取时源代码的修改时间,用于父设计器对比是否用冲突
* @param force,时间戳冲突时是否强制保存
*/
save(name: string, source: string, timestamp: number, force: boolean) : Promise<Boolean>
/**
* (子=>父)
* @param name 读取数据类型定义
*/
dataType(name: string) : Promise<DataType>
/**
* (子=>父)
* 读取可用的代码表
*/
codes() : Promise<[DataType]>
/**
* (父=>子)
* 关闭此设计器
*/
close() : void
}
/**
* 设计器源代码
*/
interface DesignerSource {
/**
* 源代码(一般为YAML)
*/
source: string
/**
* 源代码最后修改时间的
*/
timestamp: number
/**
* 设计内容对应的主数据类型
*/
data: string
/**
* 数据类型是否允许设计器编辑
*/
dataUpdate: boolean
}
/**
* 数据类型
*/
interface DataType {
/**
* 数据类型名
*/
name: string
/**
* 显示名
*/
text: string
/**
* 字段列表
*/
fields: [DataField]
}
/**
* 数据字段
*/
interface DataField {
/**
* 字段名
*/
name: string
/**
* 字段描述
*/
text: string
/**
* 字段数据类型
*/
type: string
/**
* 字段暗示(text、value、icon、tooltip)
*/
kind: string
/**
* 字段分组,用于重复节
*/
group: string
}- 使用GraphQL规范。
- 待完善。
type query {
designerSource(name:String, ) : DesignerSource
designerDataSchemas() : [ DataSchema! ]
}
type mutation {
createDesignerSource(name:String, timestamp:Int, source: String)
updateDesignerSource()
}
type DesignerSource {
timestamp: Int
# 源代码
source: String
# 主数据结构
schema: DataType
# 主数据结构是否允许更改
schemaUpdate: Boolean
}
type DataType {
# 字段列表
fields: [ DataField ]
}