uni-flow-design 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +36 -0
- package/README.md +443 -0
- package/dist/flowDesign/type.d.ts +281 -0
- package/dist/index.es.js +1431 -0
- package/dist/index.umd.js +24 -0
- package/dist/module.d.ts +38 -0
- package/dist/services.d.ts +4 -0
- package/dist/style.css +1 -0
- package/package.json +63 -0
package/README.en.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# uni-flow-design
|
|
2
|
+
|
|
3
|
+
#### Description
|
|
4
|
+
{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
|
|
5
|
+
|
|
6
|
+
#### Software Architecture
|
|
7
|
+
Software architecture description
|
|
8
|
+
|
|
9
|
+
#### Installation
|
|
10
|
+
|
|
11
|
+
1. xxxx
|
|
12
|
+
2. xxxx
|
|
13
|
+
3. xxxx
|
|
14
|
+
|
|
15
|
+
#### Instructions
|
|
16
|
+
|
|
17
|
+
1. xxxx
|
|
18
|
+
2. xxxx
|
|
19
|
+
3. xxxx
|
|
20
|
+
|
|
21
|
+
#### Contribution
|
|
22
|
+
|
|
23
|
+
1. Fork the repository
|
|
24
|
+
2. Create Feat_xxx branch
|
|
25
|
+
3. Commit your code
|
|
26
|
+
4. Create Pull Request
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
#### Gitee Feature
|
|
30
|
+
|
|
31
|
+
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
|
|
32
|
+
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
|
|
33
|
+
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
|
|
34
|
+
4. The most valuable open source project [GVP](https://gitee.com/gvp)
|
|
35
|
+
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
|
|
36
|
+
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
package/README.md
ADDED
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
# uni-flow-design
|
|
2
|
+
|
|
3
|
+
一个零接口依赖的流程设计器组件库。宿主只需要提供 DOM 容器,即可通过 `new UniFlowDesign(container, options)` 挂载流程画布;节点设置抽屉、流程属性、保存接口由宿主应用自行实现。
|
|
4
|
+
|
|
5
|
+
README 会作为 npm 包详情页的主要展示内容。发布到 npm 前建议保持这份文档和 `dist/module.d.ts` 一致。
|
|
6
|
+
|
|
7
|
+
## 特性
|
|
8
|
+
|
|
9
|
+
- 基于 Vue 3 和 ant-design-vue,产物以 library mode 输出。
|
|
10
|
+
- 可在 Vue、React 或普通 Web 页面中使用。
|
|
11
|
+
- 支持开始、审批、抄送、处理、条件分支节点。
|
|
12
|
+
- 支持缩放、全屏、节点增删、条件分支增删。
|
|
13
|
+
- 点击节点只抛出 `node-click`,宿主自行渲染设置抽屉。
|
|
14
|
+
- 支持 `flowOptions` 控制可新增节点类型、最小节点数量、节点展示文案。
|
|
15
|
+
- 导出完整 TypeScript 类型和工具方法。
|
|
16
|
+
|
|
17
|
+
## 安装
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm add uni-flow-design
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
宿主还需要安装 peer dependencies:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pnpm add vue@^3.2.25 ant-design-vue@3.2.20 @ant-design/icons-vue@^7.0.1 dayjs@^1.11.13 lodash@^4.17.21
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
宿主入口需要引入样式:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import 'ant-design-vue/dist/antd.variable.min.css';
|
|
33
|
+
import 'uni-flow-design/dist/style.css';
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 快速开始
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { UniFlowDesign } from 'uni-flow-design';
|
|
40
|
+
import 'ant-design-vue/dist/antd.variable.min.css';
|
|
41
|
+
import 'uni-flow-design/dist/style.css';
|
|
42
|
+
|
|
43
|
+
const designer = new UniFlowDesign('#flow-root', {
|
|
44
|
+
uiOptions: {
|
|
45
|
+
primaryColor: '#1677ff'
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
designer.on('node-click', (payload) => {
|
|
50
|
+
// 宿主在这里打开自己的设置抽屉
|
|
51
|
+
// 抽屉保存后调用 designer.updateNode(payload.uid, editedNode)
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
function onSave() {
|
|
55
|
+
if (!designer.validate()) {
|
|
56
|
+
designer.markInvalid();
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const flow = designer.getValue();
|
|
61
|
+
// 调用宿主自己的保存接口
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 页面销毁时调用
|
|
65
|
+
designer.unmount();
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
页面容器需要有明确高度:
|
|
69
|
+
|
|
70
|
+
```html
|
|
71
|
+
<div id="flow-root" style="height: 100vh"></div>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Vue 示例
|
|
75
|
+
|
|
76
|
+
```vue
|
|
77
|
+
<template>
|
|
78
|
+
<div style="display:flex;flex-direction:column;height:100vh">
|
|
79
|
+
<div style="padding:12px;text-align:right">
|
|
80
|
+
<button @click="onSave">保存</button>
|
|
81
|
+
</div>
|
|
82
|
+
<div ref="root" style="flex:1;min-height:0"></div>
|
|
83
|
+
</div>
|
|
84
|
+
</template>
|
|
85
|
+
|
|
86
|
+
<script setup lang="ts">
|
|
87
|
+
import { onBeforeUnmount, onMounted, ref } from 'vue';
|
|
88
|
+
import { UniFlowDesign, NodeType, type NodeClickPayload, type FlowNode } from 'uni-flow-design';
|
|
89
|
+
import 'ant-design-vue/dist/antd.variable.min.css';
|
|
90
|
+
import 'uni-flow-design/dist/style.css';
|
|
91
|
+
|
|
92
|
+
const root = ref<HTMLElement | null>(null);
|
|
93
|
+
let designer: UniFlowDesign | undefined;
|
|
94
|
+
|
|
95
|
+
onMounted(() => {
|
|
96
|
+
if (!root.value) return;
|
|
97
|
+
|
|
98
|
+
designer = new UniFlowDesign(root.value, {
|
|
99
|
+
flowOptions: {
|
|
100
|
+
addableNodeTypes: [NodeType.Approval, NodeType.Cc, NodeType.Transactor, NodeType.Condition],
|
|
101
|
+
display: {
|
|
102
|
+
startLabel: '发起人'
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
designer.on('node-click', (payload: NodeClickPayload) => {
|
|
108
|
+
openNodeDrawer(payload, (editedNode: FlowNode) => {
|
|
109
|
+
designer?.updateNode(payload.uid, editedNode);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
function onSave() {
|
|
115
|
+
if (!designer?.validate()) {
|
|
116
|
+
designer?.markInvalid();
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const flow = designer.getValue();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
onBeforeUnmount(() => designer?.unmount());
|
|
123
|
+
</script>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## React 示例
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
import { useEffect, useRef } from 'react';
|
|
130
|
+
import { UniFlowDesign } from 'uni-flow-design';
|
|
131
|
+
import 'ant-design-vue/dist/antd.variable.min.css';
|
|
132
|
+
import 'uni-flow-design/dist/style.css';
|
|
133
|
+
|
|
134
|
+
export default function FlowPage() {
|
|
135
|
+
const rootRef = useRef<HTMLDivElement | null>(null);
|
|
136
|
+
|
|
137
|
+
useEffect(() => {
|
|
138
|
+
if (!rootRef.current) return;
|
|
139
|
+
|
|
140
|
+
const designer = new UniFlowDesign(rootRef.current, {});
|
|
141
|
+
designer.on('node-click', (payload) => {
|
|
142
|
+
// 打开宿主自己的节点设置面板
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
return () => designer.unmount();
|
|
146
|
+
}, []);
|
|
147
|
+
|
|
148
|
+
return <div ref={rootRef} style={{ height: '100vh' }} />;
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## 参数
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
export interface UniFlowDesignProps {
|
|
156
|
+
defaultValue?: FlowNode | string;
|
|
157
|
+
isPreviewStatus?: boolean;
|
|
158
|
+
flowOptions?: FlowOptions;
|
|
159
|
+
uiOptions?: FlowUiOptions;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export interface FlowUiOptions {
|
|
163
|
+
primaryColor?: string;
|
|
164
|
+
theme?: 'light' | 'dark';
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
| 参数 | 类型 | 默认值 | 说明 |
|
|
169
|
+
| --- | --- | --- | --- |
|
|
170
|
+
| `defaultValue` | `FlowNode \| string` | 默认开始节点 | 初始流程 JSON,可传对象或 JSON 字符串 |
|
|
171
|
+
| `isPreviewStatus` | `boolean` | `false` | 预览态;为 `true` 时隐藏编辑入口并禁用节点点击 |
|
|
172
|
+
| `flowOptions` | `FlowOptions` | 见下方 | 画布能力与展示配置 |
|
|
173
|
+
| `uiOptions` | `FlowUiOptions` | 见下方 | UI 配置,例如主题色、明暗主题 |
|
|
174
|
+
|
|
175
|
+
### uiOptions
|
|
176
|
+
|
|
177
|
+
| 参数 | 默认值 | 说明 |
|
|
178
|
+
| --- | --- | --- |
|
|
179
|
+
| `primaryColor` | `#40a9ff` | 主题主色,需要宿主引入 antd variable CSS |
|
|
180
|
+
| `theme` | `'light'` | 画布明暗主题初始值,运行时可用 `setTheme` 切换 |
|
|
181
|
+
|
|
182
|
+
### flowOptions
|
|
183
|
+
|
|
184
|
+
节点类型统一用 `NodeType` 枚举表示:
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
export enum NodeType {
|
|
188
|
+
Launch = 'LAUNCH', // 发起 / 开始
|
|
189
|
+
Approval = 'APPROVAL', // 审批
|
|
190
|
+
Cc = 'CC', // 抄送
|
|
191
|
+
Transactor = 'TRANSACTOR', // 处理
|
|
192
|
+
Condition = 'CONDITION', // 条件分支
|
|
193
|
+
ConditionTerm = 'CONDITION_TERM' // 条件项(条件分支内的一条条件)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface FlowOptions {
|
|
197
|
+
addableNodeTypes?: AddableNodeKind[];
|
|
198
|
+
minNodeCounts?: Partial<Record<AddableNodeKind, number>>;
|
|
199
|
+
display?: FlowDisplayOptions;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// 可新增的节点类型(不含发起节点)
|
|
203
|
+
export type AddableNodeKind =
|
|
204
|
+
| NodeType.Approval
|
|
205
|
+
| NodeType.Cc
|
|
206
|
+
| NodeType.Transactor
|
|
207
|
+
| NodeType.Condition;
|
|
208
|
+
|
|
209
|
+
export interface FlowDisplayOptions {
|
|
210
|
+
startLabel?: string;
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
| 参数 | 说明 |
|
|
215
|
+
| --- | --- |
|
|
216
|
+
| `addableNodeTypes` | 允许新增的节点类型。可选 `NodeType.Approval` 审批、`NodeType.Cc` 抄送、`NodeType.Transactor` 处理、`NodeType.Condition` 条件分支。默认全部允许 |
|
|
217
|
+
| `minNodeCounts` | 节点最小保留数量,例如 `{ [NodeType.Approval]: 1 }` 表示至少保留 1 个审批节点 |
|
|
218
|
+
| `display.startLabel` | 开始节点显示文案,默认 `发起人` |
|
|
219
|
+
|
|
220
|
+
节点标题的取值规则:
|
|
221
|
+
|
|
222
|
+
- 开始节点(`NodeType.Launch`)始终显示 `display.startLabel`。
|
|
223
|
+
- 其余节点统一显示节点自身的 `name`。新建节点的默认 `name` 为内置文案(审批 / 抄送 / 处理 / 条件判断),改名通过 `setNodeName(uid, name)` 写入 `node.name` 即可反映到画布。
|
|
224
|
+
|
|
225
|
+
示例:只允许新增审批节点,并至少保留一个审批节点:
|
|
226
|
+
|
|
227
|
+
```ts
|
|
228
|
+
new UniFlowDesign('#flow-root', {
|
|
229
|
+
flowOptions: {
|
|
230
|
+
addableNodeTypes: [NodeType.Approval],
|
|
231
|
+
minNodeCounts: { [NodeType.Approval]: 1 },
|
|
232
|
+
display: {
|
|
233
|
+
startLabel: '发起'
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## 事件
|
|
240
|
+
|
|
241
|
+
```ts
|
|
242
|
+
designer.on('node-click', (payload) => {});
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
```ts
|
|
246
|
+
export interface NodeClickPayload {
|
|
247
|
+
node: FlowNode;
|
|
248
|
+
nodeConfigAll: FlowNode;
|
|
249
|
+
type: FlowNodeKind;
|
|
250
|
+
uid: FlowId;
|
|
251
|
+
conditionTermIndex?: number;
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
| 字段 | 说明 |
|
|
256
|
+
| --- | --- |
|
|
257
|
+
| `node` | 被点击节点的副本 |
|
|
258
|
+
| `nodeConfigAll` | 当前整棵流程树 |
|
|
259
|
+
| `type` | 节点类型(`NodeType`):`Launch` 开始,`Approval` 审批,`Cc` 抄送,`Transactor` 处理,`Condition` 条件分支 |
|
|
260
|
+
| `uid` | 节点唯一标识,写回节点时使用 |
|
|
261
|
+
| `conditionTermIndex` | 仅条件分支有效,表示点击的是第几个条件项 |
|
|
262
|
+
|
|
263
|
+
### 在抽屉里设置节点名称
|
|
264
|
+
|
|
265
|
+
监听 `node-click` 打开业务抽屉,确定时调用 `setNodeName(uid, name)` 写回,画布标题即显示该 `name`(开始节点除外,始终显示 `startLabel`):
|
|
266
|
+
|
|
267
|
+
```ts
|
|
268
|
+
const designer = new UniFlowDesign('#flow-root');
|
|
269
|
+
|
|
270
|
+
designer.on('node-click', (payload) => {
|
|
271
|
+
// 打开宿主自己的抽屉,初始值取 payload.node.name
|
|
272
|
+
openDrawer(payload.node.name, (newName: string) => {
|
|
273
|
+
designer.setNodeName(payload.uid, newName); // 确定保存,画布即时更新
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## 实例方法
|
|
279
|
+
|
|
280
|
+
| 方法 | 返回值 | 说明 |
|
|
281
|
+
| --- | --- | --- |
|
|
282
|
+
| `on('node-click', fn)` | `void` | 监听节点点击 |
|
|
283
|
+
| `getValue()` | `FlowNode` | 获取当前画布流程树 |
|
|
284
|
+
| `setValue(value)` | `unknown` | 整树覆盖当前画布 |
|
|
285
|
+
| `updateNode(uid, node)` | `unknown` | 按 `uid` 写回宿主抽屉编辑后的节点 |
|
|
286
|
+
| `setNodeName(uid, name)` | `boolean` | 按 `uid` 更新节点名称,命中返回 `true`。画布标题即显示该 `name`(开始节点除外) |
|
|
287
|
+
| `setTheme(mode)` | `unknown` | 运行时切换明暗主题,`mode` 取 `'light'` 或 `'dark'`,画布即时变色 |
|
|
288
|
+
| `validate()` | `boolean` | 校验流程是否配置完整,`true` 表示通过 |
|
|
289
|
+
| `markInvalid(show?)` | `unknown` | 高亮未配置完整的节点 |
|
|
290
|
+
| `unmount()` | `void` | 卸载组件实例 |
|
|
291
|
+
|
|
292
|
+
## 明暗主题
|
|
293
|
+
|
|
294
|
+
构造时用 `theme` 设初始值,页面里的明暗开关调用 `setTheme(mode)` 即时切换,无需重建实例:
|
|
295
|
+
|
|
296
|
+
```ts
|
|
297
|
+
const designer = new UniFlowDesign('#flow-root', { theme: 'light' });
|
|
298
|
+
|
|
299
|
+
// 页面开关
|
|
300
|
+
themeSwitch.onChange((checked) => {
|
|
301
|
+
designer.setTheme(checked ? 'dark' : 'light');
|
|
302
|
+
});
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
画布所有可变颜色都走 `--uf-*` CSS 变量(定义在挂载根元素上),需要微调配色时,可在宿主样式里覆盖:
|
|
306
|
+
|
|
307
|
+
```css
|
|
308
|
+
/* 覆盖暗色画布背景与节点卡片色 */
|
|
309
|
+
.uni-flow-design[data-theme="dark"] {
|
|
310
|
+
--uf-canvas-bg: #18181b;
|
|
311
|
+
--uf-node-bg: #27272a;
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
常用变量:`--uf-canvas-bg`(画布背景)、`--uf-node-bg`(节点卡片)、`--uf-text` / `--uf-text-secondary`(文字)、`--uf-line`(连线)、`--uf-border`(分隔线)、`--uf-approve-bg` / `--uf-handle-bg` / `--uf-send-bg`(审批/处理/抄送节点底色)。
|
|
316
|
+
|
|
317
|
+
> antd 的抽屉、下拉、tooltip 等组件由宿主提供,其暗色样式需宿主自行配置(如 antd 的 `theme.darkAlgorithm`);本组件的 `theme` 只负责画布自身。
|
|
318
|
+
|
|
319
|
+
## 工具方法
|
|
320
|
+
|
|
321
|
+
```ts
|
|
322
|
+
import {
|
|
323
|
+
NodeType,
|
|
324
|
+
createDefaultFlow,
|
|
325
|
+
flowCheckIsSetting,
|
|
326
|
+
flowTransformData,
|
|
327
|
+
flowTransToXML
|
|
328
|
+
} from 'uni-flow-design';
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
| 导出 | 说明 |
|
|
332
|
+
| --- | --- |
|
|
333
|
+
| `NodeType` | 节点类型枚举(字符串值),用于 `addableNodeTypes`、`payload.type` 比较等 |
|
|
334
|
+
| `createDefaultFlow()` | 生成默认开始节点流程 |
|
|
335
|
+
| `flowCheckIsSetting(flow)` | 检查流程是否存在未配置项 |
|
|
336
|
+
| `flowTransformData(flow)` | 保存前转换流程数据,补齐流转关系 |
|
|
337
|
+
| `flowTransToXML(flow)` | 将流程 JSON 转为 Flowable XML |
|
|
338
|
+
|
|
339
|
+
## 数据类型
|
|
340
|
+
|
|
341
|
+
包内导出常用类型:
|
|
342
|
+
|
|
343
|
+
```ts
|
|
344
|
+
import type {
|
|
345
|
+
FlowId,
|
|
346
|
+
FlowNode,
|
|
347
|
+
FlowNodeKind,
|
|
348
|
+
FlowOptions,
|
|
349
|
+
FlowUiOptions,
|
|
350
|
+
FlowUser,
|
|
351
|
+
AddableNodeKind,
|
|
352
|
+
FlowDisplayOptions
|
|
353
|
+
} from 'uni-flow-design';
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
## UMD 使用
|
|
357
|
+
|
|
358
|
+
UMD 产物不会打包 peer dependencies。使用前需要先准备这些全局变量:
|
|
359
|
+
|
|
360
|
+
- `Vue`
|
|
361
|
+
- `antd`
|
|
362
|
+
- `IconsVue`
|
|
363
|
+
- `dayjs`
|
|
364
|
+
- `_`
|
|
365
|
+
|
|
366
|
+
```html
|
|
367
|
+
<link rel="stylesheet" href="https://unpkg.com/ant-design-vue@3.2.20/dist/antd.variable.min.css" />
|
|
368
|
+
<link rel="stylesheet" href="./dist/style.css" />
|
|
369
|
+
<div id="flow-root" style="height: 100vh"></div>
|
|
370
|
+
|
|
371
|
+
<script src="https://unpkg.com/vue@3.2.25/dist/vue.global.prod.js"></script>
|
|
372
|
+
<script src="https://unpkg.com/dayjs@1/dayjs.min.js"></script>
|
|
373
|
+
<script src="https://unpkg.com/lodash@4/lodash.min.js"></script>
|
|
374
|
+
<script src="https://unpkg.com/ant-design-vue@3.2.20/dist/antd.min.js"></script>
|
|
375
|
+
<script src="https://unpkg.com/@ant-design/icons-vue@7/dist/index.umd.min.js"></script>
|
|
376
|
+
<script src="./dist/index.umd.js"></script>
|
|
377
|
+
<script>
|
|
378
|
+
const designer = new window.UniFlowDesign.UniFlowDesign('#flow-root', {});
|
|
379
|
+
</script>
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
## 本地开发
|
|
383
|
+
|
|
384
|
+
```bash
|
|
385
|
+
pnpm install
|
|
386
|
+
pnpm dev
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
构建:
|
|
390
|
+
|
|
391
|
+
```bash
|
|
392
|
+
pnpm build
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
类型检查:
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
npx tsc --noEmit
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
## 发布到 npm
|
|
402
|
+
|
|
403
|
+
npm 包详情页会展示 `README.md`,所以需要有 npm 展示文档。发布前建议执行:
|
|
404
|
+
|
|
405
|
+
```bash
|
|
406
|
+
pnpm build
|
|
407
|
+
npx tsc --noEmit
|
|
408
|
+
npm pack --dry-run
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
确认包内容至少包含:
|
|
412
|
+
|
|
413
|
+
- `package.json`
|
|
414
|
+
- `README.md`
|
|
415
|
+
- `dist/index.es.js`
|
|
416
|
+
- `dist/index.umd.js`
|
|
417
|
+
- `dist/style.css`
|
|
418
|
+
- `dist/module.d.ts`
|
|
419
|
+
- `dist/services.d.ts`
|
|
420
|
+
- `dist/flowDesign/type.d.ts`
|
|
421
|
+
|
|
422
|
+
首次发布:
|
|
423
|
+
|
|
424
|
+
```bash
|
|
425
|
+
npm login
|
|
426
|
+
npm publish --access public
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
后续发布前需要更新版本号:
|
|
430
|
+
|
|
431
|
+
```bash
|
|
432
|
+
npm version patch
|
|
433
|
+
npm publish
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
## 设计边界
|
|
437
|
+
|
|
438
|
+
组件只负责流程画布本身:
|
|
439
|
+
|
|
440
|
+
- 组件负责:画布渲染、节点增删、条件分支增删、缩放、全屏、节点点击事件。
|
|
441
|
+
- 宿主负责:节点设置抽屉、保存按钮、流程属性、接口请求、业务校验。
|
|
442
|
+
|
|
443
|
+
这个边界能保证组件不绑定具体业务模块,也不会因为新增业务场景再改组件内部。
|