Skip to content

uploader fix multiple#2611

Closed
HeyShinner wants to merge 2 commits intojdf2e:nextfrom
kurisu994:Shinner-components-uploader-code-renew
Closed

uploader fix multiple#2611
HeyShinner wants to merge 2 commits intojdf2e:nextfrom
kurisu994:Shinner-components-uploader-code-renew

Conversation

@HeyShinner
Copy link
Copy Markdown

@HeyShinner HeyShinner commented Sep 23, 2024

Summary by CodeRabbit

  • 新功能

    • 上传组件新增可选回调函数 onOverLimit,用于处理文件超出限制的情况。
  • 变更

    • 包名称已更新为 @feewee/nutui-react-taro
    • 发布配置中的注册表 URL 已更改为 https://registry.feewee.cn

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Sep 23, 2024

Walkthrough

此次变更主要涉及两个方面。首先,package.json 文件中的包名从 @nutui/nutui-react-taro 更改为 @feewee/nutui-react-taro,同时更新了发布配置中的注册表 URL。其次,在 Uploader 组件中新增了一个可选的回调函数 onOverLimit,用于处理文件数量超过限制的情况,并对文件上传逻辑进行了相应修改,以确保文件列表的更新一致性。

Changes

文件路径 修改摘要
package.json 包名更新:@nutui/nutui-react-taro@feewee/nutui-react-taro;注册表 URL 更新:https://registry.npmjs.org/https://registry.feewee.cn
src/packages/uploader/uploader.tsx 新增属性:onOverLimit?: (files: File[]) => void,用于处理文件数量超限的情况。

Possibly related PRs

  • docs(uploader): update #2265: 该 PR 涉及与 Uploader 组件相关的文档更新,可能间接与本 PR 中 Uploader 功能的修改相关。

Poem

在兔子洞里,变更如春风,
包名新换,注册表更动。
上传器里,限额新添,
文件超限,回调来援。
兔子欢跳,庆祝这变,
代码如歌,乐在其中! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range and nitpick comments (3)
package.json (1)

44-44: 注意:包的发布仓库 URL 已从 https://registry.npmjs.org/ 更改为 https://registry.feewee.cn

这一改动表明该包将发布到一个不同的,可能是私有的仓库。这需要:

  1. 更新 .npmrc 文件或任何用于发布包的 CI/CD 脚本,以使用新的仓库 URL。

请注意,这一改动不会影响该包的使用者,因为他们仍将从默认的 npm 仓库安装它。但是,它将影响包本身的发布过程。请务必更新所有相关的发布配置。

src/packages/uploader/uploader.tsx (2)

Line range hint 290-315: 合理的重构

引入临时数组 _files 来累积 FileItem 对象,并在最后批量更新 fileList 状态的做法是合理的重构。这避免了不必要的重渲染,提高了性能。同时,将 fileItem 的构建逻辑与 fileList 的更新分离,使得代码更加清晰和可读。

可以进一步优化

可以考虑在 reader.onload 回调之外构建 fileItem,这样可以避免在回调中执行过多的逻辑,进一步提高代码的可读性和可维护性。


334-334: 合理的回调触发

在文件数超出限制时触发 onOverLimit 回调函数,这与新增的 onOverLimit 属性的预期行为是一致的。

考虑优化回调参数

传入 onOverLimit 回调函数的是过滤后可能已经被截断的文件数组,这可能与用户选择的原始文件数组不完全一致。建议考虑传入原始的文件数组,以便让使用者获得完整的信息。

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 33208c7 and c75090c.

Files selected for processing (2)
  • package.json (2 hunks)
  • src/packages/uploader/uploader.tsx (5 hunks)
Additional comments not posted (2)
src/packages/uploader/uploader.tsx (2)

67-67: 合理的接口扩展

onOverLimit 回调函数的引入是一个很好的改进,它允许使用者自定义处理文件数超出限制的逻辑。这提高了组件的灵活性。


146-146: 保持接口一致性

InternalUploader 组件中新增的 onOverLimit 属性与 UploaderProps 接口定义保持了一致,这很好地保证了内外的统一性。

@@ -1,5 +1,5 @@
{
"name": "@nutui/nutui-react-taro",
"name": "@feewee/nutui-react-taro",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

重大改动:包名已从 @nutui/nutui-react-taro 更改为 @feewee/nutui-react-taro

这是一个破坏性的改动,需要:

  1. 更新代码库中所有的导入语句以使用新的包名。
  2. 更新文档和任何对旧包名的引用。
  3. 进行一次主版本号的升级,因为这是一个破坏性的改动。
  4. 通知所有该包的使用者更新其依赖项到新的包名和版本。

未能更新导入语句将导致运行时错误。请务必彻底检查并更新所有的引用。

@HeyShinner HeyShinner closed this Sep 23, 2024
@HeyShinner HeyShinner deleted the Shinner-components-uploader-code-renew branch September 23, 2024 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants