designer

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package designer 定义 go-wind-ui 流程设计器与 go-wind-flow 之间的 JSON 契约(designer-json-v1):领域结构 + UI 元数据(节点坐标、边拐点)。

契约细节见仓库 docs/designer_contract.md。要点:

  • 节点/边的业务字段与引擎 flow.Node / flow.Edge 一一对应(同一 json tag), 设计器保存的文档可直接 Deploy(Format = "designer-json-v1",亦可留空—— 内容嗅探对 '{' 开头且含 "version":1 的文档命中本格式);
  • UI 元数据(ui.*)由服务端原样保留在文档里,引擎忽略;
  • 定义不可变:设计器每次"发布"= Deploy 新版本。

Index

Constants

View Source
const FormatName = "designer-json-v1"

FormatName 注册到引擎的格式标识。

View Source
const Version = 1

Version 当前契约版本。

Variables

This section is empty.

Functions

func Parse

func Parse(data []byte) (*flow.Definition, error)

Parse 设计器文档 → Definition。

func Write

func Write(def *flow.Definition) ([]byte, error)

Write Definition → 设计器文档。

Types

type Document

type Document struct {
	Version int    `json:"version"`
	Key     string `json:"key"`
	Name    string `json:"name,omitempty"`
	Nodes   []Node `json:"nodes"`
	Edges   []Edge `json:"edges"`
}

Document 设计器文档。

type Edge

type Edge struct {
	ID        string  `json:"id"`
	Source    string  `json:"source"`
	Target    string  `json:"target"`
	Name      string  `json:"name,omitempty"`
	Condition string  `json:"condition,omitempty"`
	IsDefault bool    `json:"isDefault,omitempty"`
	UI        *EdgeUI `json:"ui,omitempty"`
}

Edge 设计器连线:source/target 遵循设计器(bpmn-js)惯例, 解析时映射为领域的 From/To。

type EdgeUI

type EdgeUI struct {
	// Waypoints 拐点序列(画布坐标,不含端点)。
	Waypoints [][2]float64 `json:"waypoints,omitempty"`
}

EdgeUI 连线的 UI 元数据。

type Exporter

type Exporter struct{}

Exporter 实现 flow.Exporter。

func (Exporter) Export

func (Exporter) Export(def *flow.Definition) ([]byte, error)

Export 从 Definition 导出设计器文档。 注意:引擎内的 Definition 不携带 UI 元数据(ui 字段为 nil)—— 宿主如需保坐标,应保存原始文档而非依赖导出。

func (Exporter) Format

func (Exporter) Format() string

type Importer

type Importer struct{}

Importer 实现 flow.Importer。

func (Importer) Format

func (Importer) Format() string

func (Importer) Import

func (Importer) Import(data []byte) (*flow.Definition, error)

type Node

type Node struct {
	flow.Node
	UI *Position `json:"ui,omitempty"`
}

Node 设计器节点:领域字段(内嵌 flow.Node,json tag 一致)+ UI 元数据。

type Position

type Position struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

Position 节点在画布上的坐标。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL