diff --git a/packages/core/client/docs/zh-CN/core/flow-engine/demos/quickstart.tsx b/packages/core/client/docs/zh-CN/core/flow-engine/demos/quickstart.tsx index c917c415a6..6758bf4605 100644 --- a/packages/core/client/docs/zh-CN/core/flow-engine/demos/quickstart.tsx +++ b/packages/core/client/docs/zh-CN/core/flow-engine/demos/quickstart.tsx @@ -6,7 +6,7 @@ import React from 'react'; // 实现一个本地存储的模型仓库,负责模型的持久化 class FlowModelRepository implements IFlowModelRepository { // 从本地存储加载模型数据 - async load(uid: string) { + async findOne({ uid }) { const data = localStorage.getItem(`flow-model:${uid}`); if (!data) return null; return JSON.parse(data); diff --git a/packages/core/client/docs/zh-CN/core/flow-engine/flow-action.md b/packages/core/client/docs/zh-CN/core/flow-engine/flow-action.md index c52686c218..79fe9aa217 100644 --- a/packages/core/client/docs/zh-CN/core/flow-engine/flow-action.md +++ b/packages/core/client/docs/zh-CN/core/flow-engine/flow-action.md @@ -180,3 +180,33 @@ steps: { - 支持多种定义方式,适应不同复杂度的业务场景。 - 可通过 `uiSchema` 和 `defaultParams` 配置参数界面和默认值,提升易用性。 - 合理使用 `paramsRequired` 和 `hideInSettings`,提升操作安全性和灵活性。 + +--- + +## 示例:在 Drawer 中使用 + +以下示例演示如何在 Drawer 中使用 FlowAction,并传递 `currentDrawer` 到 `sharedContext`。 + +```tsx +// 1. 先声明 currentDrawer +let currentDrawer: any; + +// 2. 定义内容组件,确保 currentDrawer 已赋值 +function DrawerContent() { + return ( +
+ +
+ ); +} + +// 3. 打开 Drawer,并赋值 currentDrawer +currentDrawer = ctx.globals.drawer.open({ + title: '命令式 Drawer', + width: 800, + content: , +}); +``` diff --git a/packages/core/client/docs/zh-CN/core/flow-engine/flow-model-repository.md b/packages/core/client/docs/zh-CN/core/flow-engine/flow-model-repository.md index c46c7fc75d..b5de975136 100644 --- a/packages/core/client/docs/zh-CN/core/flow-engine/flow-model-repository.md +++ b/packages/core/client/docs/zh-CN/core/flow-engine/flow-model-repository.md @@ -4,7 +4,7 @@ ## 主要方法 -- **load(uid: string): Promise** +- **findOne(query: Query): Promise** 根据唯一标识符 uid 从远程加载模型数据。 - **save(model: FlowModel): Promise** @@ -19,7 +19,8 @@ class FlowModelRepository implements IFlowModelRepository { constructor(private app: Application) {} - async load(uid: string) { + async findOne(query) { + const { uid, parentId } = query; // 实现:根据 uid 获取模型 return null; } diff --git a/packages/core/client/docs/zh-CN/core/flow-models/demos/model-repository.tsx b/packages/core/client/docs/zh-CN/core/flow-models/demos/model-repository.tsx index 7282b847f2..06eac4dca1 100644 --- a/packages/core/client/docs/zh-CN/core/flow-models/demos/model-repository.tsx +++ b/packages/core/client/docs/zh-CN/core/flow-models/demos/model-repository.tsx @@ -4,7 +4,7 @@ import React from 'react'; class FlowModelRepository implements IFlowModelRepository { constructor(private app: Application) {} - async load(uid: string) { + async findOne({ uid, parentId }) { // implement fetching a model by id return null; } diff --git a/packages/core/client/docs/zh-CN/core/flow-models/demos/sub-model.tsx b/packages/core/client/docs/zh-CN/core/flow-models/demos/sub-model.tsx index 411a1ee211..e9708e6f5a 100644 --- a/packages/core/client/docs/zh-CN/core/flow-models/demos/sub-model.tsx +++ b/packages/core/client/docs/zh-CN/core/flow-models/demos/sub-model.tsx @@ -6,7 +6,9 @@ import { Button, Tabs } from 'antd'; import _ from 'lodash'; import React from 'react'; -class FlowModelRepository implements IFlowModelRepository> { +class FlowModelRepository + implements IFlowModelRepository> +{ get models() { const models = new Map(); for (let i = 0; i < localStorage.length; i++) { @@ -22,8 +24,12 @@ class FlowModelRepository implements IFlowModelRepository { - +class HelloFlowModel extends FlowModel<{ parent: never; subModels: { tabs: TabFlowModel[] } }> { addTab(tab: any) { // 使用新的 addSubModel API 添加子模型 const model = this.addSubModel('tabs', tab); @@ -88,7 +96,7 @@ class HelloFlowModel extends FlowModel<{parent: never, subModels: { tabs: TabFlo items={this.subModels.tabs?.map((tab) => ({ key: tab.getProps().key, label: tab.getProps().label, - children: tab.render() + children: tab.render(), }))} tabBarExtraContent={