Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@eternalsky
Copy link
Collaborator

No description provided.

@eternalsky eternalsky added the WIP Working in Progress / 有人跟进中 label Mar 29, 2023
@github-actions
Copy link

github-actions bot commented Mar 29, 2023

ChatGPT Code Review:

CodeReview:

  1. 在 .eslintrc.js 中添加了 '@typescript-eslint/no-redeclare' 规则,避免出现重复声明的变量名;
  2. 在 BuiltinSimulatorHost 类中添加了一个 faultComponentMap 属性,用于存储渲染失败组件的映射关系;
  3. 在 ReactSimulatorRenderer 中的 Renderer 组件中,添加了 faultComponentMap 和 customCreateElement 两个属性,分别用于获取 faultComponent 的映射关系以及自定义渲染元素的方法;
  4. 在 Renderer 中的 BaseRenderer 类的 constructor 方法中,对 thisRequiredInJSE 属性进行了修改,更改了它的默认值;
  5. 在 Renderer 中的 parseExpression 函数中,添加了一个 logScope 参数,用于记录函数解析出错时所在的作用域。

修改建议:

  1. 在 .eslintrc.js 中添加规则需要开发人员注意改规则的目的和适用范围,防止不必要的错误和警告;
  2. BuiltinSimulatorHost 中的 faultComponentMap 属性未对外暴露,建议添加注释说明其用途;
  3. ReactSimulatorRenderer 中的 Renderer 中的 faultComponentMap 和 customCreateElement 属性建议添加注释说明其用途;
  4. Renderer 中的 BaseRenderer 类的 constructor 方法中建议添加注释说明发生了什么修改以及为什么要这样做;
  5. parseExpression 函数中的 logScope 参数建议添加注释说明其用途。

生成的合适的 commit message:feat: add faultComponentMap and modify thisRequiredInJSE in Renderer.

@eternalsky
Copy link
Collaborator Author

优化效果:
截屏2023-03-29 下午8 19 17

组件设计态报错做了更友好展示。
出错提示不管是 parse 出错,还是代码执行出错都有对应的 componentName 输出。

目前差一个点没有完成,即不知道如何判断运行在 ReactSimulatorRenderer 还是 ReactRenderer
@liujuping 目前是否有比较好的判断方法。

@JackLian JackLian removed their request for review March 30, 2023 01:56
import './component.css';

export default function componentRendererFactory(): IBaseRenderComponent {
const { PureComponent, createElement } = adapter.getRuntime();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这部分感觉用配置更好一些,目前有 faultComponent 的配置,可以考虑加一个 lowcodeFaultComponent 的配置,这样就不需要考虑是在 react-simulator 里面,还是 react-render 内。

image

对于低代码平台来说,只需要在插件中通过 AliLowcodeEgine.config.set('lowcodeFaultComponent', xxx) 对低代码组件的提示进行定制即可。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lowcodeFaultComponent 这个配置,是定制 ComponentRender 的 FaultComponent 吗~

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

目前 faultComponent 的问题是,虽然可以替换默认的,但是会把包括 Page/Component/Block 等一些列的都替换掉。那我们是直接增加不同类型的 faultComponent,如增加 componentFaultComponent 还是说,把这个 faultComponent 本身能力增强,可以配置多个。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以把本身能力增强,可以配置多个。包括:低代码组件、区块等等。

@eternalsky eternalsky removed the WIP Working in Progress / 有人跟进中 label Mar 31, 2023
@liujuping liujuping merged commit d64da1e into develop Mar 31, 2023
@liujuping liujuping deleted the feat/component_error_boundry branch March 31, 2023 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants