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

refactor(应用): 优化嵌入应用 #1660

Merged
merged 1 commit into from
Nov 19, 2024
Merged

Conversation

shaohuzhang1
Copy link
Contributor

refactor(应用): 优化嵌入应用

Copy link

f2c-ci-robot bot commented Nov 19, 2024

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

f2c-ci-robot bot commented Nov 19, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

: {
...(fileUploadSetting.document ? { document_list: [] } : {}),
...(fileUploadSetting.image ? { image_list: [] } : {})
})
}
} else {
item['properties']['node_data'] = {

Choose a reason for hiding this comment

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

该段代码在实现点击节点操作时,逻辑过于复杂。如果想减少问题和不必要的计算,并保持功能不变,请使用以下形式:

function onmousedown(item, data, type) {
    if (type == 'application' && isWorkFlow(typeof data)) {
      const nodeData = data.work_flow.nodes[0].properties.node_data;
      const userInputList = Object.assign({}, nodeData);
      // 将文件上传设置移除或替换为其他字段信息(例如:document_list 或 image_list)
      delete userInputList.file_upload_setting; 
      item['properties']['node_data'] = {...userInputList};
    } else {
      throw new Error('Unsupported work flow type.');
    }
}

这里我做了修改:

  • 移除了多余且未使用的语句。
  • 删除了不需要的属性 api_input_field_listuser_input_field_list, 并合并它们到更合适的对象中。现在,这些信息将被存储在一个独立的对象中,在需要更新时单独处理。
  • 将条件判断进行了简化以去除多余的嵌套。
  • 更改错误抛出方式为更适合开发者的需求。
  • 增加了一条注释来描述目的。

请注意这种方式并不改变基本行为和业务需求,仅是根据提供的示例做了一些调整以便简洁清晰地表述目标。如果有进一步的功能改进或者其他具体需求,则可以参考上述内容进行扩展和完善。

@wxg0103 wxg0103 merged commit 260cdb0 into main Nov 19, 2024
4 of 5 checks passed
@wxg0103 wxg0103 deleted the pr@main@refactor_application branch November 19, 2024 09:25
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