@huanban/rulego-editor-vue 1.3.12 → 1.3.13
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.md +34 -4
- package/dist/index.cjs.js +7 -7
- package/dist/index.esm.js +2932 -2932
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
- **开箱即用** — 提供 `<RuleGoEditor />` 组件,一行代码嵌入编辑器
|
|
11
11
|
- **Vue 3 Composables** — `useEditorCore`、`useEditorTheme`、`useEditorI18n`
|
|
12
|
-
- **事件监听** — 支持 `@
|
|
12
|
+
- **事件监听** — 支持 `@node-click`、`@ready`、`@change` 等 Vue 事件;保存接管通过 `options.onSave`
|
|
13
13
|
- **完整内置 UI** — 工具栏、侧边栏、属性抽屉、设置、AI 助理、运行调试由 core 统一提供
|
|
14
14
|
- **独立管理组件** — `WorkflowList` / `WorkflowInfoPanel` 可组合出列表、详情和编辑器联动页面
|
|
15
15
|
- **响应式状态** — 所有状态自动转为 Vue `ref`,模板中直接使用
|
|
@@ -36,8 +36,8 @@ npm install @huanban/rulego-editor-ui
|
|
|
36
36
|
:data="ruleChainData"
|
|
37
37
|
:components="components"
|
|
38
38
|
:options="editorOptions"
|
|
39
|
-
@save="onSave"
|
|
40
39
|
@node-click="onNodeClick"
|
|
40
|
+
@change="onChange"
|
|
41
41
|
/>
|
|
42
42
|
</template>
|
|
43
43
|
|
|
@@ -59,8 +59,8 @@ const editorOptions = computed(() => ({
|
|
|
59
59
|
showRunButton: true,
|
|
60
60
|
}))
|
|
61
61
|
|
|
62
|
-
const onSave = (data) => console.log('保存:', data)
|
|
63
62
|
const onNodeClick = (node) => console.log('点击节点:', node)
|
|
63
|
+
const onChange = () => console.log('画布已变更')
|
|
64
64
|
</script>
|
|
65
65
|
```
|
|
66
66
|
|
|
@@ -104,13 +104,43 @@ watch(isReady, (ready) => {
|
|
|
104
104
|
|
|
105
105
|
| 事件 | 参数 | 说明 |
|
|
106
106
|
|------|------|------|
|
|
107
|
-
| `@save` | `SaveEventData` |
|
|
107
|
+
| `@save` | `SaveEventData` | 兼容事件;默认保存不依赖它,接管保存请使用 `options.onSave` |
|
|
108
108
|
| `@node-click` | `NodeData` | 节点点击时触发 |
|
|
109
109
|
| `@ready` | — | 编辑器就绪时触发 |
|
|
110
110
|
| `@change` | — | 画布数据变化 |
|
|
111
111
|
| `@edge-click` | `EdgeData` | 连线点击 |
|
|
112
112
|
| `@deploy` | `chainId, action` | 部署/下线/重载;部署对应 `start`,下线对应 `stop` |
|
|
113
113
|
|
|
114
|
+
### 保存协议
|
|
115
|
+
|
|
116
|
+
默认不要传 `options.onSave`。只要在 `options.apiBase` 配置后台地址,保存按钮会直接调用:
|
|
117
|
+
|
|
118
|
+
```text
|
|
119
|
+
POST {apiBase}/rules/:id
|
|
120
|
+
GET {apiBase}/rules/:id
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
第二次 `GET` 用于回读校验,只有后端返回的数据与当前画布一致时才会显示已保存。
|
|
124
|
+
|
|
125
|
+
只有宿主确实要完全接管保存时才在 `options` 中传 `onSave`。接管后必须返回明确结果:
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
const editorOptions = computed(() => ({
|
|
129
|
+
apiBase: apiBase.value,
|
|
130
|
+
onSave: async (data: any) => {
|
|
131
|
+
const id = data?.ruleChain?.id
|
|
132
|
+
const response = await fetch(`${apiBase.value}/rules/${encodeURIComponent(id)}`, {
|
|
133
|
+
method: 'POST',
|
|
134
|
+
headers: { 'Content-Type': 'application/json', ...fetchHeaders() },
|
|
135
|
+
body: JSON.stringify(data),
|
|
136
|
+
})
|
|
137
|
+
return response.ok ? { success: true } : { success: false, message: `HTTP ${response.status}` }
|
|
138
|
+
},
|
|
139
|
+
}))
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
单纯监听 `@save` 不再短路内置保存。只想打印日志或观察画布变化时,请使用 `@change`、`@node-click` 或浏览器调试日志。
|
|
143
|
+
|
|
114
144
|
### `<WorkflowList />` 管理列表
|
|
115
145
|
|
|
116
146
|
`WorkflowList` 是独立管理组件,不是编辑器。它负责查询、搜索、创建、部署/下线、复制、删除和选择规则链;进入画布编辑需要通过 `:on-design` 切换到 `<RuleGoEditor />`。
|