Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore:事件动作增加循环调用检查 #7074

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hsm-lv
Copy link
Collaborator

@hsm-lv hsm-lv commented Jun 2, 2023

What

🤖 Generated by Copilot at 60e8169

This pull request adds a new feature to the amis framework to support circular events and actions for various components, such as Form, Page, Service, and Wizard. It also improves the event dispatching mechanism to include the source component information and prevent infinite loops. It modifies several files in the amis-core and amis packages, such as Form.tsx, SchemaRenderer.tsx, factory.tsx, and renderer-event.ts.

🤖 Generated by Copilot at 60e8169

Sing, O Muse, of the cunning RendererComponent
That with circularEventAction checked the loops of fate
And saved the Form and Service from endless turmoil
When they dispatched events with their own context and state

Why

How

🤖 Generated by Copilot at 60e8169

  • Add a circularEventAction property to the RendererComponent type and various components to declare the event names and action types for circular detection (link, link, link, link, link)
  • Add a logic to check for circular event action configurations in the dispatchEvent method of the SchemaRenderer class using the checkCircular function from amis-core utils (link, link, link, link)
  • Pass the this argument to the dispatchEvent function to identify the source component of various events in the Form, Page, Service, and Wizard components (link, link, link, link, link, link, link, link, link, link, link, link, link, link)
  • Remove unused imports from Page component (link, link)

@hsm-lv hsm-lv requested a review from 2betop June 2, 2023 11:00
@github-actions github-actions bot added the chore label Jun 2, 2023
@github-actions
Copy link

github-actions bot commented Jun 2, 2023

👍 Thanks for this!
🏷 I have applied any labels matching special text in your issue.

Please review the labels and make any necessary changes.

@iceqing
Copy link
Contributor

iceqing commented Sep 9, 2023

我们最近写的一些amis页面也出现了循环调用,导致页面卡死,但是排查起来很痛苦。
希望这个feature能合并,这个一个非常好且实用的功能,amis缺失了循环检测功能。

@2betop 您添加了request-changes标签,这个PR有什么问题吗?能明确指出下是哪里有问题不?

@2betop
Copy link
Collaborator

2betop commented Sep 12, 2023

request-changes 是要求修改的意思, 目前的方案不够准确,应该用实际运行时堆栈的方式检测,目前只判断一层会大概率失败,而且还忽略了执行条件

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants