diff --git a/packages/core/client/docs/zh-CN/core/event-and-filter/demos/events/configurable-action.tsx b/packages/core/client/docs/zh-CN/core/event-and-filter/demos/events/configurable-action.tsx index b541e3fcfd..6f41e61584 100644 --- a/packages/core/client/docs/zh-CN/core/event-and-filter/demos/events/configurable-action.tsx +++ b/packages/core/client/docs/zh-CN/core/event-and-filter/demos/events/configurable-action.tsx @@ -139,36 +139,63 @@ eventFlowManager.addFlow({ ], }); +const PARAMS = { + events: { + 'button-id': { + stepParams: { + 'message-step': { + title: '消息标题', + content: '这是一条测试消息', + type: 'info', + }, + }, + }, + }, + filters: {}, +}; + +const getParams = async (id: string) => { + return new Promise((resolve) => { + setTimeout(() => { + resolve(PARAMS['events'][id]); // 模拟异步获取 + }, 1000); + }); +}; + +const setParams = async (id: string, params: Record) => { + return new Promise((resolve) => { + setTimeout(() => { + PARAMS['events'][id] = params; // 模拟异步更新 + resolve(params); + }, 1000); + }); +}; + // 主演示组件 const ConfigurableActionDemo = () => { - const [currentParams, setCurrentParams] = useState>({ - title: '消息标题', - content: '这是一条测试消息', - type: 'info', - }); - + const componentId = 'button-id'; // 打开配置弹窗 - const showConfig = () => { + const showConfig = async () => { const step = eventFlowManager.getFlow('message-flow').getStep('message-step'); const ctx = { payload: { step, - onChange: (values) => { - setCurrentParams(values); + onChange: async (values) => { + await setParams(componentId, values); }, - currentParams, + currentParams: await getParams(componentId), }, }; eventBus.dispatchEvent('configure:click', ctx); }; // 触发消息动作 - const triggerAction = () => { + const triggerAction = async () => { const ctx = { payload: {}, meta: { stepParams: { - 'message-step': currentParams, + 'message-step': await getParams(componentId), }, }, }; @@ -182,15 +209,6 @@ const ConfigurableActionDemo = () => { 点击"配置参数"按钮修改消息的标题、内容和类型,然后点击"执行动作"查看效果。 -
- 当前配置: -
    -
  • 标题: {currentParams.title}
  • -
  • 内容: {currentParams.content}
  • -
  • 类型: {currentParams.type}
  • -
-
-